jquery hover event doesn't work with select option tag in google chrome?

你离开我真会死。 提交于 2019-12-01 11:20:13

问题


I have a simple select tag

   <select>
        <option value="a">a</option>
        <option value="b">b</option>
        <option value="c">c</option>
        <option value="d">d</option>
    </select>

I want add hover event on option

   $('select option').hover(function(){
        console.log($(this).val());
    },function(){
        console.log("mouse out");
    });

However, it only works in Firefox, not in Chrome. How can I solve this problem? Is it a bug in jquery? Is there some hack?


回答1:


hover event will not fire for option elements in Chrome and IE, might be in other browsers as well. You could try using some custom script for that: http://peterned.home.xs4all.nl/csshover.html



来源:https://stackoverflow.com/questions/10240205/jquery-hover-event-doesnt-work-with-select-option-tag-in-google-chrome

易学教程内所有资源均来自网络或用户发布的内容,如有违反法律规定的内容欢迎反馈
该文章没有解决你所遇到的问题?点击提问,说说你的问题,让更多的人一起探讨吧!