Jel*_*lle 15 html javascript jquery
我有这个函数来移动绝对DIV,我想执行setTimeout函数.但是,当涉及行$().finish()时,JQuery跳出hover()函数.如何在完成()之后执行某些操作?
$('#header li[class!="logo"]').hover(function () {
var leftStart = $(this).position().left;
var width = ($(this).width() / 2) - 22;
$('#header .pointerarrow').animate({ left: leftStart + width }, 400);
}, function () {
$('#header .pointerarrow').finish();
//######This does not excecute###########
setTimeout(function () {
alert('succeeded');
var l = $('#header li[class="current"]').position().left;
var b = ($('#header li[class="current"]').width() / 2) - 22;
$('#header .pointerarrow').css({ left: l + b });
}, 500);
});
Run Code Online (Sandbox Code Playgroud)
小智 45
$('#header .pointerarrow').animate(
{ left: linksstart + breedte },
400, function() {
// Animation complete.
});
Run Code Online (Sandbox Code Playgroud)
完成动画写入功能块后想要执行的操作.
尝试这个:
$('#header .pointerarrow').animate({ left: linksstart + breedte }, 400);
$('#header .pointerarrow').promise().done(function(){
/* PUT FUNCTION HERE */
});
Run Code Online (Sandbox Code Playgroud)
我希望这有帮助!