How to stop toggle event from being fired multiple times on mouseenter/mouseleave?
我正在使用jQuery使用jQuery切换方法来切换
感谢!
两件事:
如果要同时使用
使用触发动画时,习惯使用
所以:
1 2 3 4 5 | $("div.someclass").hover(function() { $("...").stop().fadeIn("slow"); }, function() { $("...").stop().fadeOut("slow"); }); |
注意:替换
除了Cletus的正确答案外,我想指出使用
1 2 3 4 5 6 | $("div.someclass").on("mouseenter", function() { $("...").stop().fadeIn("slow"); }); $("div.someclass").on("mouseleave", function() { $("...").stop().fadeOut("slow"); }); |
这是一个jsFiddle示例:)
您可以使用更常见的
但是请勿在鼠标事件上使用
更好:只需使用