jQuery 中的 stop( clearQueue, gotoEn

首页 / jQuery入门教程 / jQuery 中的 stop( clearQueue, gotoEn

stop([clearQueue,gotoEnd])方法停止所有指定元素上的所有当前正在运行的动画。

stop( [clearQueue, gotoEnd ]) - 语法

selector.stop( [clearQueue], [gotoEnd] ) ;

这是此方法使用的所有参数的描述-

无涯教程网

  • clearQueue  -  这是可选的布尔参数。设置为true会清除动画队列,有效地停止所有排队的动画。

  • gotoEnd      -  这是可选的布尔参数。布尔值(true/false),当设置为true时,会导致当前播放的动画立即完成,包括在show和hide上重置原始样式并调用回调函数。

stop( [clearQueue, gotoEnd ]) - 示例

以下是一个简单的示例,简单说明了此方法的用法-

链接:https://www.learnfk.comhttps://www.learnfk.com/jquery/effect-stop.html

来源:LearnFk无涯教程网

<html>
   <head>
      <title>The jQuery Example</title>
      <script type="text/javascript" 
         src="https://ajax.googleapis.com/ajax/libs/jquery/2.1.3/jquery.min.js">
      </script>
		
      <script type="text/javascript" language="javascript">
   
         $(document).ready(function() {

            $("#go").click(function(){
               $(".target").animate({left: '+=100px'}, 2000);
            });

            $("#stop").click(function(){
               $(".target").stop();
            });

            $("#back").click(function(){
               $(".target").animate({left: '-=100px'}, 2000);
            });
				
         });
      </script>
		
      <style>
         p {background-color:#bca; width:250px; border:1px solid green;}   
         div{position: absolute; left: 50px; top:300px;}
      </style>
   </head>
	
   <body>
      <p>Click on any of the following buttons:</p>
		
      <button id="go"> GO</button>
      <button id="stop"> STOP </button>
      <button id="back"> BACK </button>

      <div class="target">
         <img src="/jquery/images/jquery.jpg" alt="jQuery" />
      </div>
   </body>
</html>

这将产生以下输出-

祝学习愉快!(内容编辑有误?请选中要编辑内容 -> 右键 -> 修改 -> 提交!)

技术教程推荐

深入浅出gRPC -〔李林锋〕

深入拆解Java虚拟机 -〔郑雨迪〕

MySQL实战45讲 -〔林晓斌〕

零基础学Java -〔臧萌〕

摄影入门课 -〔小麥〕

Go 语言项目开发实战 -〔孔令飞〕

搞定音频技术 -〔冯建元 〕

超级访谈:对话汤峥嵘 -〔汤峥嵘〕

Go进阶 · 分布式爬虫实战 -〔郑建勋〕

好记忆不如烂笔头。留下您的足迹吧 :)