jQuery animate动画排队执行

<!DOCTYPE html>
<html lang="en">
<head>
    <meta charset="UTF-8">
    <title>Title</title>
    <style>
        .box{
            width:100px;
            height:100px;
            position: absolute;
            left:200px;
            top:200px;
            border-radius:10px;
            box-shadow: 0 0 20px #999;
            line-height: 300px;
            text-align: center;
            font-size: 50px;
            color:#fff;
        }
        #box1{
            background:#5298c7;
        }
    </style>
</head>
<body>
<div id="box1" class="box"></div>
<script src="../js/jquery-1.12.4.js"></script>
<script>
    $('#box1').click(function () {
        var $this=$(this);
        //第一个动画执行完后执行第二个动画
        $this.animate({left:'+=50'},1000);
        $this.animate({top:'+=50'},1000)
    })
</script>
</body>
</html>

猜你喜欢

转载自blog.csdn.net/qiankui/article/details/82975838