动画完成后,如何在JQuery中做些什么 [英] How to do something in JQuery after animation Finish()

查看:67
本文介绍了动画完成后,如何在JQuery中做些什么的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我有这个函数来移动绝对DIV,我想执行setTimeout函数。但是,当涉及到$()。finish()行时,JQuery跳出hover()函数。如何在finish()之后执行某些操作?

I have this function to move an absolute DIV and I want to execute the setTimeout function. However, JQuery jumps out of the hover() function when it comes to the line $().finish(). How do I execute something after the finish()?

$('#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);

});


推荐答案

$('#header .pointerarrow').animate(
    { left: linksstart + breedte },
     400, function() {
       // Animation complete.
  });

完成动画写入功能块后,您想要执行什么操作。

What ever you want to perform after complete animation write inside function block.

这篇关于动画完成后,如何在JQuery中做些什么的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆