admin管理员组文章数量:1419239
My code only works in Firefox. Why is this?
HTML:
<select id="selecter">
<option>one</option>
<option>two</option>
<option>three</option>
</select>
Javascript:
$(function() {
$(document).on("mouseover", "#selecter option",function(){
alert(1)
});
});
I'm curious why IE and chrome don't fire a mouseover event. See this JSFiddle: / (Works perfectly in Firefox.)
How can I get IE and Chrome to fire a mouseover event?
My code only works in Firefox. Why is this?
HTML:
<select id="selecter">
<option>one</option>
<option>two</option>
<option>three</option>
</select>
Javascript:
$(function() {
$(document).on("mouseover", "#selecter option",function(){
alert(1)
});
});
I'm curious why IE and chrome don't fire a mouseover event. See this JSFiddle: http://jsfiddle/yT6Y5/72/ (Works perfectly in Firefox.)
How can I get IE and Chrome to fire a mouseover event?
Share Improve this question edited Apr 2, 2014 at 0:12 Owen Versteeg 3483 silver badges14 bronze badges asked Feb 23, 2013 at 8:56 tradebel123tradebel123 4351 gold badge6 silver badges20 bronze badges3 Answers
Reset to default 4The problem is that browsers render dropdowns differently. Chrome is rendering it not as an HTML ponent but as a native GUI one. That can't have hover handlers associated to it from JS.
If you want to make sure it works on all browsers either don't use a dropdown or get a script to create a dropdown that uses HTML elements
It seems, no events are actually fired when you hover over an option in IE & chrome,
At best should should bind on the change event.
$(function() {
$("#selecter").change(function(){
alert(1);
});
});
maybe you should use , a different approach to bind the event
$(function() {
$("#selecter").mouseover(function(){
alert(1)
});
});
本文标签: javascriptIE and Chrome don39t fire a mouseover event for ltoptiongt elementsStack Overflow
版权声明:本文标题:javascript - IE and Chrome don't fire a mouseover event for <option> elements - Stack Overflow 内容由网友自发贡献,该文观点仅代表作者本人, 转载请联系作者并注明出处:http://www.betaflare.com/web/1745293176a2651920.html, 本站仅提供信息存储空间服务,不拥有所有权,不承担相关法律责任。如发现本站有涉嫌抄袭侵权/违法违规的内容,一经查实,本站将立刻删除。
发表评论