jquery 停止动画

We can use jQuery stop() function to stop the currently running animation on the matched elements.

我们可以使用jQuery stop()函数在匹配的元素上停止当前正在运行的动画。

jQuery stop() (jQuery stop())

There are two variants of jQuery stop() function.

jQuery stop()函数有两种变体。

  1. stop(boolean clearQueue, boolean jumpToEnd): Default value of both the argument is false. We can pass clearQueue as true to stop the queued animation. We can pass jumpToEnd as true to complete the current animation immediately.stop(boolean clearQueue,boolean jumpToEnd):两个参数的默认值为false。 我们可以将clearQueue传递为true来停止排队的动画 。 我们可以将jumpToEnd作为true传递,以立即完成当前动画。
  2. stop(String queue, boolean clearQueue, boolean jumpToEnd): Here we can pass the name of the queue to stop the animation, other two arguments are same as above.stop(String queue,boolean clearQueue,boolean jumpToEnd):在这里我们可以传递队列的名称来停止动画,其他两个参数与上面相同。

jQuery停止动画 (jQuery stop animation)

Here is a simple example for jQuery stop animation.

这是jQuery停止动画的简单示例。

<!DOCTYPE html>
<html>
<head>
<title> jQueryClear Queued Function</title>
<script src="jquery-3.2.1.min.js"></script>
<script>
$(document).ready(function(){$("#startbtn").click(function(){$("div").animate({height:200}, 2000 );});$("#stopbtn").click(function(){$("div").stop();});
});
</script>
</head>
<body><button id="startbtn">Start</button>
<button id="stopbtn">Stop</button><div style="background:green;height:90px;width:90px;">
</div></body>
</html>

Notice that I am not passing any parameter with stop() function call, it’s because there is only one animation and I want it to stop as soon as stop button is clicked.

请注意,我没有通过stop()函数调用传递任何参数,这是因为只有一个动画,并且我希望它在单击停止按钮后立即停止。

jQuery停止动画队列 (jQuery stop animation queue)

Here is an example where animation queue is cleared and current running animation is also stopped when stop button is clicked.

这是一个示例,其中当单击停止按钮时,清除了动画队列,并且也停止了当前正在运行的动画。

<!DOCTYPE html>
<html>
<head>
<title> jQueryClear Queued Function</title>
<script src="jquery-3.2.1.min.js"></script>
<script>
$(document).ready(function(){$("#startbtn").click(function(){$("div").animate({height:200}, 2000 );$("div").slideUp(2000 );$("div").slideDown(2000 );$("div").animate({width:300},1500);$("div").animate({height:100},1500);$("div").animate({width:100},1500);});$("#stopbtn").click(function(){// $("div").clearQueue();$("div").stop(true, false);});
});
</script>
</head>
<body><button id="startbtn">Start</button>
<button id="stopbtn">Stop</button><div style="background:green;height:90px;width:90px;">
</div></body>
</html>

Below image shows the above program in action.

下图显示了上面的程序正在运行。

That’s all for jQuery stop() function and jQuery stop animation example.

这就是jQuery stop()函数和jQuery stop动画示例的全部内容。

Reference: API Doc

参考: API文档

翻译自: https://www.journaldev.com/4647/jquery-stop-animation

jquery 停止动画

jquery 停止动画_jQuery停止动画相关推荐

  1. jQuery动画(jQuery预制动画,jQuery自定义动画,jQuery停止动画和延迟动画)

    目录 jQuery预制动画 显示隐藏动画 上拉下拉动画(高度动画) 淡入淡出动画(透明度动画) jQuery自定义动画 jQuery停止动画和延迟动画等 jQuery预制动画 jquery的预制动画 ...

  2. android 逐帧动画自动播放以及逐帧动画与渐变动画结合的停止问题

    关于逐帧动画的自动播放: android 逐帧动画一般不能直接在onCreat()方法里直接调用.start(),否则只是播放动画的第一帧,可重写onWindowFocusChanged(boolea ...

  3. hide show vue 动画_jQuery动画效果

    ---------------------------------------------------------------------------------------------------- ...

  4. html5文字飞入插件,jquery使用CSS3实现文字动画效果插件Textillate.js

    jquery使用CSS3实现文字动画效果插件Textillate.js Textillate是一款基于CSS3动画效果的 JavaScript 库,您可非常轻轻松地把这些动画效果应该于网页中的任何文字 ...

  5. jQuery——入门(二)动画

    jQuery -- 入门(二)动画/效果 一.案例解析 hide([speed,[easing],[fn]]) []:意思表示的方括号中的东西是可选的,可有可无的: []中,会有对应的参数名称[变量名 ...

  6. 四、jQuery 中的事件和动画(嘎嘎详细)

    文章目录 前言 一.事件 1.1 加载 DOM 1.1.1 执行时机 1.1.2 多次使用 1.1.3 简写方式 1.2 事件绑定 1.2.1简单使用 1.2.2 简写绑定事件 1.3 合成事件 1. ...

  7. jquery动画效果 animate() 自定义动画 stop() 停止运行动画 fadeIn()/fadeOut()/fadeTo() 淡入淡出

    jquery动画效果 今天给大家介绍一下jQuery当中的几种动画效果. . animate() 自定义动画 stop() 停止运行动画 fadeIn()/fadeOut()/fadeTo() 淡入淡 ...

  8. 锋利的Jquery【读书笔记】 -- 第四章 jQuery中的事件和动画

    锋利的Jquery读书笔记 第三章 jQuery中的DOM操作 jQuery中的事件 事件绑定 bind方法 合成事件 hover方法 toggle方法 事件冒泡 事件对象 停止事件冒泡 阻止默认行为 ...

  9. jQuery(五)--自定义动画、动画

    目录 一.自定义动画 1.1 animate() 1.2 animate()动画执行顺序 1.3 animate()动画回调函数和匀速运动 1.4 animate动画之stop()/delay() 二 ...

最新文章

  1. matlab画三维心,matlab动态三维心形(最新整理)
  2. Qt::WindowType、Qt::WidgetAttribute各个标志含义汇总
  3. Android官方开发文档Training系列课程中文版:动画视图之转场框架介绍
  4. 赞!卷积神经网络中十大拍案叫绝的操作
  5. linux之chsh命令
  6. eclipse 达梦 连接_JDBC连接达梦7数据库
  7. 『中级篇』Docker-Stack部署wordpress(49)
  8. STM32_I2SSAI
  9. android logo颜色渐变,2018,很多APP的logo渐变了 -- 渐变色教程
  10. 差分密码分析读书报告
  11. 获取企业微信code
  12. 在Node.js中了解Hello World
  13. 你必须利用备份恢复数据库,但是你没有控制文件,该如何解决问题呢?
  14. inv在线计算机,INV3062A
  15. 公司中生存奥秘诙谐解说[ZT]
  16. 数据挖掘之OneR算法(原来数据挖掘如此简单!)
  17. 2018_AAAI_Social Recommendation with an Essential Preference Space—(AAAI, 2018)
  18. pr基本图形模板无法使用_Pr基本图形模板安装教程
  19. 线程竞争导致的EOFException解决 ---  一次线上问题解决流程
  20. python 多线程利器-tomorrow

热门文章

  1. 对于C# 中事件的参数(object sender, EventArgs e)
  2. 咖啡口味介绍及存储方式
  3. [转载] strtol() -- 将字符串转换成长整型数(转载)
  4. [转载] python更新numpy_Python numpy从1.6更新到1.8
  5. [转载] Python利用openpyxl模块读取excel文件内容
  6. [转载] Python基础知识:构造函数中self用法
  7. 高速收发器之8B/10B编码
  8. 【转】高并发情况下的单例模式
  9. Eclipse 快捷键整理
  10. Weblogic Domain Template Creation Script