jquery 悬停事件不适用于谷歌浏览器中的选择选项标签? [英] jquery hover event doesn't work with select option tag in google chrome?

查看:18
本文介绍了jquery 悬停事件不适用于谷歌浏览器中的选择选项标签?的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我有一个简单的 select 标签

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>

我想在 option

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

但是,它仅适用于 Firefox,不适用于 Chrome.我怎么解决这个问题?它是jquery中的错误吗?有什么技巧吗?

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?

推荐答案

hover 事件不会在 Chrome 和 IE 中触发选项元素,可能在其他浏览器中也是如此.您可以尝试为此使用一些自定义脚本:http://peterned.home.xs4all.nl/csshover.html

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

这篇关于jquery 悬停事件不适用于谷歌浏览器中的选择选项标签?的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆