0

使用 jQuery,我正在检测 mouseenter 事件:

// triggered when mousing over the green div
$('#dock').mouseenter(function() {
    alert('moused over!');
});

但是,如果我的 div 后面有一个 select 标记,这将在它打开时触发 mouseover 事件:

    <div id="dock">
    </div>
    <div class="container">

        <select name="product_tier" id="id_product_tier">
            <option value="" selected="selected">---------</option>
            <option value="1">test-product-tier</option>
        </select>

    </div>

我已经在 Chrome 和 Chromium 27.0.1453.93(Windows:OK,OS X:OK,Linux:如上所述失败)、IE 9(Windows:OK)、Opera(Linux:OK)、Firefox 21(Linux:OK)上对此进行了测试)。

我无法在 jsFiddle 或 jsBin 上重现它,但您可以运行以下要点:https ://gist.github.com/Wilfred/5679748 。

有什么想法有什么问题吗?这是 Chrome 错误吗?

4

1 回答 1

0

这是 jQuery 1.7+ 中支持的新 jQuery 方式

$("#dock").on("click touchstart", function(event){
  alert($(this).text());
});

示例:http: //jsfiddle.net/yfHZE/

免责声明:我没有在 Linux 中尝试过,但它应该可以工作。

于 2013-05-30T19:59:23.357 回答