为什么stop()函数不能正常工作? [英] why stop() function doesn't work correctly?

查看:92
本文介绍了为什么stop()函数不能正常工作?的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我写了这个jQuery代码,但是当我尝试停止动画元素使其返回其原始位置时(使用Callback函数),它没有响应,但是变慢了! . 我正在使用jquery-1.6.4版本

I wrote this jQuery code, but when i tried to stop the animated elements while it is returning to its original position (using Callback function),it didn't responded, but it become slower !! . I am using jquery-1.6.4 version

<script type="text/javascript">

    $(function () {
        $("#right").click(function () {
            $(".theDiv0").animate({ left: "800px" }, 2000, "swing", returnToLeft);
            $(".theDiv1").animate({ left: "800px" }, 2000, "linear", returnToLeft);
        });
        function returnToLeft() {
            $(".theDiv0").animate({ left: "10px" }, 2000, "swing");
            $(".theDiv1").animate({ left: "10px" }, 2000, "linear");
        }

        $("#stop").click(function () {
            $(".theDiv0,.theDiv1").stop();
           });
    });
</script>

任何建议/解决方案

推荐答案

尝试使用.stop(true)

有关更多信息,请参见文档.如果我是对的,那应该真的停止了动画.

See the docs for further informations. If I'm right, this should really stop the animation.

这篇关于为什么stop()函数不能正常工作?的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

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