Hi Team
I have a dropdownlist of popular,latest and best buying category list. Now how to i reference these to jquery so when user if select popular the cart-container has an image of those category appears, same applies with other from the dropdownlist?
// html code
Naimish MakwanaPosted May 8, 2023, 4:27 AM
You can use jQuery to listen for the
clickevent on each of the dropdown items and then display the corresponding image based on the selected option. Here's an example:HTML:
jQuery:
In this example, we've added a
data-categoryattribute to each dropdown item to store the corresponding category. Then, in the jQuery code, we listen for theclickevent on the dropdown items and retrieve the selected category using thedatamethod. We then remove any existing images in the cart container using theemptymethod and display the corresponding image using theappendmethod.Thanks