如何禁用mouseout事件的子元素触发?

Sander Versluys提出了一个问题:How to disable mouseout events triggered by child elements?,或许与您遇到的问题类似。

回答者Jeff Wardbytebrite给出了该问题的处理方式:

The question is a bit old, but I ran into this the other day.

The simplest way to do this with recent versions of jQuery is to use the mouseenter and mouseleave events rather than mouseover and mouseout.

You can test the behavior quickly with:

$(".myClass").on( {
   'mouseenter':function() { console.log("enter"); },
   'mouseleave':function() { console.log("leave"); }
});

希望本文对你有帮助,欢迎支持JavaScript中文网

原文链接:stackoverflow.com

上一篇:我怎么能从JavaScript时代起秒?
下一篇:我怎么有HAML内联JavaScript呢?

相关推荐

官方社区

扫码加入 JavaScript 社区