jquery之stop方法的使用

stop方法:停止当前正在执行的动画,有两个参数:第一个参数为clearQueue的布尔值,第二个参数为jumpToEnd的布尔值。

clearQueue:是否清除动画队列,true为清除,false则不清除;

jumpToEnd:是否跳转到当前动画的最终效果,true为跳转,false则停留在当前状态;

栗子:

<!DOCTYPE html>
<html lang="zh-CN">
<head>
  <meta charset="UTF-8">
  <title>Title</title>
  <style>
    div {
      width: 200px;
      height: 200px;
      background-color: pink;
      display: none;
    }
  </style>
</head>
<body>
<input type="button" value="开始">
<input type="button" value="结束">
<div></div>
<script src="script/jquery-1.12.4.js"></script>
<script>
  $(function () {
    $("input").eq(0).click(function () {
      $("div").slideDown(4000).slideUp(4000);
    });
    $("input").eq(1).click(function () {
           // $("div").stop().animate();
      $("div").stop(true, true);
    })
  });
</script>
</body>
</html>

例子中两个参数都为true,可以自由变换一下参数,了解其不同的效果

猜你喜欢

转载自blog.csdn.net/line233/article/details/84288338
今日推荐