delay()--一个很常用的jquery方法,制作页面动画效果的利器

学一个jquery方法,必须先从小例子学起,直接上一个简单的例子: 为了理解,这个例子只是在http://www.runoob.com/try/try.php?filename=tryjquery_eff_delay2 上面稍作修改

<!DOCTYPE html>
<html>
<head>
<script src="http://libs.baidu.com/jquery/1.10.2/jquery.min.js">
</script>
<script>
$(document).ready(function()
  {
  $("#btn1").click(function(){
    $("div").animate({height:"200px"});
    $("div").animate({width:"300px"});
    $("div").delay(3200).animate({height:"300px"});
    $("div").delay(1200).animate({width:"600px"});
  });
});
</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:100px;width:100px;margin:6px;">

</div>
<p><button id="btn1">Animate</button></p>
</body>
</html>


需要注意的是,因为配合使用的是animate(),因此点击事件触发后,每一个执行代码都不是瞬发的,按照先后顺序,要等上一句执行代码动画执行完毕,才会执行下一句; 例如 $("div").animate({height:"200px"}); 这句的动画完全执行完,才会执行 $("div").animate({height:"200px"}); 这句

转载于:https://my.oschina.net/daladida/blog/724252

评论
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

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

抵扣说明:

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

余额充值