Alo*_*lon 5 html javascript jquery
我有一段代码基本上说:如果你翻过来,那么另一件事就出现了,如果你推出那么它就会消失.
问题是,如果我用鼠标翻转过多次,那么元素会出现/消失太多次(因为我错误地为它创建了很多事件)
我的代码看起来像这样:
$('div.accordionContent').mouseenter(function()
{
$(this).find(".something").animate({left: 0}, 300)}).mouseleave(function() {
$(this).find(".something").animate({
left: -200}, 500);;
});
Run Code Online (Sandbox Code Playgroud)
如何告诉它以避免多次悬停?
如果有帮助我使用jQuery 1.4.3
而不是避免多次触发,尝试在启动另一个之前停止动画.
$('div.accordionContent').mouseenter(function() {
$(this).find(".something").stop().animate(...)
});
Run Code Online (Sandbox Code Playgroud)