开发者

jquery mouseenter with live() doesn't work on chrome and explorer?

I'm trying to do something when the user hovers on the container, regardless of its children. As I understand it should look something like this:

$('.element').live({
    mouseenter: function() { console.log('entered'); },
    mouseleave: function() { console.log('exited'); }
});

And the HTML:

<div class="element">
    <div>
        <img src="aaa.png">
        <div>aa</div>
开发者_JAVA百科        <div>
            <div>a</div>
            <div>b</div>
        </div>
    </div>
    <div>
        blabla
        <ul>
        </ul>
    </div>
    <div>
        <div>a</div>
        <div>a</div>
        <div>a</div>
        <div>a</div>
    </div>
</div>

For some reason this doesn't work. When I hover over the element, it still listens to hover events on the child elements and logs. Maybe because it is live?


So apparently it's a bug in jquery 1.60. Once I switched to 1.62 everything started working as expected.


-- edit: wrong idea --

http://jsfiddle.net/dRaw6/ seems to work

0

上一篇:

下一篇:

精彩评论

暂无评论...
验证码 换一张
取 消

最新问答

问答排行榜