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

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

问题描述

我有一个简单的选择标记

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>

我想在选项上添加悬停事件

   $('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?

推荐答案

悬停事件不会触发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天全站免登陆