嘿,我不知道标题是否是说出我的问题的正确方法,但我会在这里解释一下。
所以我的错误是everthyng在前几次有效,但是在徘徊并且更频繁地离开div之后它不再起作用它开始滞后动画开始10秒后更多。
我尝试用event.stopPropagation()
修复它,但这不起作用。
这里是html
[...]
<div class="box" id="box_1">
<div class="content_box hidden" id="cont_1">
<div class="con" id="con_1">Test1</div>
</div>
</div>
[...]
和Jquery代码
$( ".box" ).mouseover(function(event) {
event.stopPropagation();
var attr = $( this ).attr("id");
var i = 0;
for(i = 1;i<=9;i++){
if(attr=="box_"+i){
$('#con_'+i).removeClass('hidden');
$('#cont_'+i).removeClass('hidden');
$(this).stop().animate({width: "300px"}, 100);
$('#cont_'+i).stop().delay(100).animate({width: "250px"},1).animate({height: "400px"},500);
}
}
$(this).delay(100).mouseleave(function(e) {
e.stopPropagation();
for(var i = 1;i<=9;i++){
if(attr=="box_"+i){
$('.con').addClass('hidden');
$('#cont_'+i).stop().animate({height: "0px"},500).animate({wdith: "0px"});
$(this).stop().delay(500).animate({
width: "50px"
});
}
}
});
});
答案 0 :(得分:0)
.delay()方法最适合在排队的jQuery之间延迟 效果。因为它是有限的 - 例如,它没有提供一种方法 取消延迟-.delay()不是JavaScript本机的替代品 setTimeout函数,可能更适合某些用途 例。