该方式停止和继续动画,而在鼠标悬停的JQuery及移出时 [英] The way to stop and continue animation while mouseover and mouseout in JQuery

查看:186
本文介绍了该方式停止和继续动画,而在鼠标悬停的JQuery及移出时的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

例如:

一个简单的例子来说明:

a simple example to explain:

$('.moveDiv').animate({ "margin-left": 2000 }, 20000, 'linear');

moveDiv元素将移动,当它被加载,现在到了离开的时候了鼠标移到 moveDiv元素,我希望它停下来,继续当移动鼠标到移动

the moveDiv element would move to left when it was loaded,and now, when the mouse move over the moveDiv element, I wish it to stop and continue to move when the mouse move out!

任何想法?

我发现这个code这个计算器问题href=\"http://stackoverflow.com/questions/2143056/seamless-jquery-marquee\">,所以,我只是想修改code,使其可以停止和继续动画时,鼠标悬停!

I found this code in this question of stackoverflow,so , I just want to modify the code to make it could stop and continue animation when mouse hover!!

的code 的演示

推荐答案

暂停/恢复动画插件

    $(document).ready(function () {

        $(".moveDiv")
        .mouseover(function () { $(this).pauseAnimation(); })
        .mouseout(function () { $(this).resumeAnimation(); })
        .startAnimation({ "margin-left": 2000 }, 20000, 'linear');

    });

这篇关于该方式停止和继续动画,而在鼠标悬停的JQuery及移出时的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

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