user198989
user198989

Reputation: 4665

Change option background color on hover?

How can I change the background color when user hovers it ? I have tried this but it's not working.

<select>
<option>bmw</option>
<option>audi</option>
<option>mercedes</option>
</select>



$('option').hover(function(){
$(this).css("background-color","#FFFFCC");
}); 

Upvotes: 4

Views: 12037

Answers (3)

Bakudan
Bakudan

Reputation: 19492

Since you already use jQuery, there is a pretty nice plugin - image-dropdown + demo from the makers.

Upvotes: 0

David Houde
David Houde

Reputation: 4778

You cannot use option in this way. The best solution would be styling something similar with <ul> and <li> and interacting with JS.

Upvotes: 1

shanabus
shanabus

Reputation: 13115

hover event can not be bound to an option tag. I'll update this post if I find the documentation or proof that says so. In my experience, this cannot be done.

Upvotes: 0

Related Questions