我的jQuery第八天 animate作中的queue队列

我的jQuery第八天

jQuery中的animate作中的queue队列

queue and dequeue and clearQueue

 <style>
        .demo{
            width: 100px;
            height: 100px;
            background-color: aquamarine;
        }
    </style>
</head>
<body>
    <div class="demo"></div>
    <script src="./js/jquery-1.8.3.min.js"></script>
    <script>
        // queue
        // type content,可以传两个参数,第一个参数是名称,第二个是函数
        // jQ{chain : []} 在jQ对象中创建三个数组每一个索引是一个方法
        $('.demo').queue('chain',function(next){
            console.log('over1')
            next();
        }).queue('chain',function(next){
            console.log('over2')
             next();
        }).queue('chain',function(next){
            console.log('over3')
        })
        console.log($('.demo').queue('chain'))
        $('.demo').dequeue('chain');
        //$('.demo').clearQueue()清空队列,所有队列
        //在函数中加入next就相当于在执行的最后一段取next一直将队列执行完。
        //当执行完去输出dequeue的时候,chain的数组为空
        //如果不加next,则每一次执行dequeue的时候只会执行一次队列
    </script>

队列结合animate

<script>
    $('.demo').on('click',function(){
            $(this).dequeue('chain'); 
        }).queue('chain', function(next){
            $(this).animate({width:220,height:220,left:100,top:100})
            next()
        }).queue('chain', function(next){
            $(this).animate({width:340,height:340,left:340,top:340})
            next()
        }).queue('chain', function(next){
            $(this).animate({width:460,height:460,left:460,top:460})
            next()
        })
</script>
  • 0
    点赞
  • 0
    收藏
    觉得还不错? 一键收藏
  • 0
    评论

“相关推荐”对你有帮助么?

  • 非常没帮助
  • 没帮助
  • 一般
  • 有帮助
  • 非常有帮助
提交
评论
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

当前余额3.43前往充值 >
需支付:10.00
成就一亿技术人!
领取后你会自动成为博主和红包主的粉丝 规则
hope_wisdom
发出的红包
实付
使用余额支付
点击重新获取
扫码支付
钱包余额 0

抵扣说明:

1.余额是钱包充值的虚拟货币,按照1:1的比例进行支付金额的抵扣。
2.余额无法直接购买下载,可以购买VIP、付费专栏及课程。

余额充值