[英]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");
});
You cannot use option in this way. 您不能以这种方式使用选项。 The best solution would be styling something similar with
<ul>
and <li>
and interacting with JS. 最好的解决方案是使用
<ul>
和<li>
进行类似的设计,并与JS进行交互。
hover
event can not be bound to an option
tag. hover
事件不能绑定到option
标记。 I'll update this post if I find the documentation or proof that says so. 如果我找到说明的文档或证明,我会更新这篇文章。 In my experience, this cannot be done.
根据我的经验,这是不可能做到的。
声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.