实例 jQuery 演示如何使用 delay() 让动画延时

x
 
<!DOCTYPE html>
<html>
<head>
<script src="https://libs.baidu.com/jquery/2.1.4/jquery.min.js"></script>
<script>
$(document).ready(function(){
  $("#btn1").click(function(){
    $("div").animate({height: "150px"});
    $("div").animate({width: "150px"});
    $("div").delay(1200).animate({height: "300px"});
  });
});
</script>
</head>
<body>
<p>This example demonstrates the animate() method with three merged boxes.</p>
<p>The third box is set to delay() for 1200 milliseconds.</p>
<div style="background:purple;height:75px;width:75px;margin:6px;"></div>
<p><button id="btn1">Animate</button></p>
</body>
</html>
                    

输出结果