Change background color of options on hover?

How can I change the background color when the user freezes? I tried this, but it does not work.

<select> <option>bmw</option> <option>audi</option> <option>mercedes</option> </select> $('option').hover(function(){ $(this).css("background-color","#FFFFCC"); }); 
+4
source share
3 answers

You cannot use the option in this way. A better solution would be to mix something like <ul> and <li> and interact with JS.

+1
source

hover event cannot be attached to the option tag. I will update this post if I find documentation or evidence that says so. In my experience, this is not possible.

0
source

Since you are already using jQuery, there is a pretty good plugin - image-dropdown + demo from the creators .

0
source

Source: https://habr.com/ru/post/1400785/


All Articles