jquery delay()介绍及使用指南
作者:bea
delay(duration,[queueName]) 设置一个延时来推迟执行队列中之后的项目。 jQuery 1.4新增。用于将队列中的函数延时执行。他既可以推迟动画队列的执行,也可以用于自定义队列。 duration:延时时间,单位:毫秒 queueName:队列名词,默认是Fx,动画队列。 参数 描述 speed 可选。规定延迟的速度。 可能的值: 毫秒 "slow" "fast
delay(duration,[queueName])
设置一个延时来推迟执行队列中之后的项目。 jQuery 1.4新增。用于将队列中的函数延时执行。他既可以推迟动画队列的执行,也可以用于自定义队列。
duration:延时时间,单位:毫秒
queueName:队列名词,默认是Fx,动画队列。
参数
描述
speed
可选。规定延迟的速度。 可能的值:
毫秒
"slow"
"fast"
queueName
可选。规定队列的名称。 默认是 "fx",标准效果队列。
$("button").click(function(){
$("#div1").delay("slow").fadeIn();
$("#div2").delay("fast").fadeIn();
});
完整测试代码:
<!DOCTYPE html>
<html>
<head>
<script src="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>This example sets different speed values for the delay() method.</p>
<button>Click to fade in boxes with a delay</button>
<br><br>
<div id="div1" style="width:90px;height:90px;display:none;background-color:black;"></div><br>
<div id="div2" style="width:90px;height:90px;display:none;background-color:green;"></div><br>
<div id="div3" style="width:90px;height:90px;display:none;background-color:blue;"></div><br>
<div id="div4" style="width:90px;height:90px;display:none;background-color:red;"></div><br>
<div id="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);
});
有用 | 无用
设置一个延时来推迟执行队列中之后的项目。 jQuery 1.4新增。用于将队列中的函数延时执行。他既可以推迟动画队列的执行,也可以用于自定义队列。
duration:延时时间,单位:毫秒
queueName:队列名词,默认是Fx,动画队列。
参数
描述
speed
可选。规定延迟的速度。 可能的值:
毫秒
"slow"
"fast"
queueName
可选。规定队列的名称。 默认是 "fx",标准效果队列。
$("button").click(function(){
$("#div1").delay("slow").fadeIn();
$("#div2").delay("fast").fadeIn();
});
完整测试代码:
<!DOCTYPE html>
<html>
<head>
<script src="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>This example sets different speed values for the delay() method.</p>
<button>Click to fade in boxes with a delay</button>
<br><br>
<div id="div1" style="width:90px;height:90px;display:none;background-color:black;"></div><br>
<div id="div2" style="width:90px;height:90px;display:none;background-color:green;"></div><br>
<div id="div3" style="width:90px;height:90px;display:none;background-color:blue;"></div><br>
<div id="div4" style="width:90px;height:90px;display:none;background-color:red;"></div><br>
<div id="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);
});
有用 | 无用
猜你喜欢
您可能感兴趣的文章:
- 初识Node.js
- node.js适合游戏后台开发吗?
- 浅析Node.js查找字符串功能
- Node.js实现在目录中查找某个字符串及所在文件
- iframe如何动态创建及释放其所占内存
- Javascript正则控制文本框只能输入整数或浮点数
- jquery制作select列表双向选择示例代码
- 一个获取第n个元素节点的js函数
- indexOf 和 lastIndexOf 使用示例介绍
- jquery实现个人中心导航菜单效果和美观都非常不错
- JavaScript判断文件上传类型的方法
- JavaScript中九种常用排序算法
- 事件委托与阻止冒泡阻止其父元素事件触发
- 解决jquery版本冲突的有效方法
- ajaxFileUpload.js插件支持多文件上传的方法
- 引用其它js时如何同时处理多个window.onload事件
- JS中自定义定时器让它在某一时刻执行
- 理解javascript中的回调函数(callback)
- 详解js闭包