jquery delay()介绍及使用指南
delay(duration,[queueName])
设置一个延时来推迟执行队列中之后的项目。
jQuery1.4新增。用于将队列中的函数延时执行。他既可以推迟动画队列的执行,也可以用于自定义队列。
duration:延时时间,单位:毫秒
queueName:队列名词,默认是Fx,动画队列。
可能的值:
speed
可选。规定延迟的速度。
queueName
可选。规定队列的名称。
默认是"fx",标准效果队列。
$("button").click(function(){
$("#div1").delay("slow").fadeIn();
$("#div2").delay("fast").fadeIn();
});
完整测试代码:
<!DOCTYPEhtml>
<html>
<head>
<scriptsrc="http://libs.baidu.com/jquery/1.10.2/jquery.min.js">
</script>
<script>
$(document).ready(function(){
$("button").click(function(){
$("#div1").delay("slow").fadeIn();
$("#div2").delay("fast").fadeIn();
$("#div3").delay(800).fadeIn();
$("#div4").delay(2000).fadeIn();
$("#div5").delay(4000).fadeIn();
});
});
</script>
</head>
<body>
<p>Thisexamplesetsdifferentspeedvaluesforthedelay()method.</p>
<button>Clicktofadeinboxeswithadelay</button>
<br><br>
<divid="div1"style="width:90px;height:90px;display:none;background-color:black;"></div><br>
<divid="div2"style="width:90px;height:90px;display:none;background-color:green;"></div><br>
<divid="div3"style="width:90px;height:90px;display:none;background-color:blue;"></div><br>
<divid="div4"style="width:90px;height:90px;display:none;background-color:red;"></div><br>
<divid="div5"style="width:90px;height:90px;display:none;background-color:purple;"></div><br>
</body>
</html>
例:
头部与底部延迟加载动画效果
$(document).ready(function(){
$('#header')
.css({'top':-50})
.delay(1000)
.animate({'top':0},800);
$('#footer')
.css({'bottom':-15})
.delay(1000)
.animate({'bottom':0},800);
});
热门推荐
1 训练狗狗憋尿
2 狗狗追踪训练
3 狗狗训练要多少钱
5 深圳狗狗训练
6 训练狗狗唤回
7 狗狗叫怎么训练
8 狗狗训练班
10 狗狗社会化训练
11 狗狗叫回训练
12 广州狗狗训练学校
13 狗狗训练躺下
14 狗狗随行训练
15 训练狗狗巡回
16 狗狗要怎么训练
17 狗狗喂食训练
18 训练狗狗躺下