返回jQuery停......登陆

jQuery停止动画学习总结

吴勇文2018-11-10 18:24:2487
<!DOCTYPE html>
<html>
<head>
    <meta charset="utf-8">
    <script src="前端课件/jQuery/jquery-3.3.1.min.js"></script>
    <style type="text/css">
       .div_1{width: 100px;height: 100px;background: red;margin-top: 30px;position: absolute;}
    </style>
</head>
<body>
    <script>
      $(document).ready(function(){
          $('#bt_1').click(function(){
             $('.div_1').animate({left:'200px'},2000)
             $('.div_1').animate({top:'200px'},2000)
             $('.div_1').animate({left:'8px',opacity:'0.5'},2000)
             $('.div_1').animate({top:'8px',opacity:'0.5'},2000)            
        })
        $('#bt_2').click(function(){
          $('.div_1').stop(true)        
        })
      })
    </script>
    <button id="bt_1">开始</button>
    <button id="bt_2">停止</button>
    <div class="div_1"></div>
</body>
</html>

通过测试stop()的确如果没有放true值只能停止第一个动画,后续动画会继续执行,放了true值后,就可以控制整个动画效果的停止位置。

最新手记推荐

• 用composer安装thinkphp框架的步骤• 省市区接口说明• 用thinkphp,后台新增栏目• 管理员添加编辑删除• 管理员添加编辑删除

全部回复(0)我要回复

暂无评论~
  • 取消回复发送
  • PHP中文网