jquery delay()介紹及使用指南
delay(duration,[queueName])
設(shè)置一個(gè)延時(shí)來(lái)推遲執(zhí)行隊(duì)列中之后的項(xiàng)目。
jQuery 1.4新增。用于將隊(duì)列中的函數(shù)延時(shí)執(zhí)行。他既可以推遲動(dòng)畫(huà)隊(duì)列的執(zhí)行,也可以用于自定義隊(duì)列。
duration:延時(shí)時(shí)間,單位:毫秒
queueName:隊(duì)列名詞,默認(rèn)是Fx,動(dòng)畫(huà)隊(duì)列。
| 參數(shù) | 描述 |
|---|---|
| speed | 可選。規(guī)定延遲的速度。
可能的值:
|
| queueName | 可選。規(guī)定隊(duì)列的名稱。 默認(rèn)是 "fx",標(biāo)準(zhǔn)效果隊(duì)列。 |
$("button").click(function(){
$("#div1").delay("slow").fadeIn();
$("#div2").delay("fast").fadeIn();
});
完整測(cè)試代碼:
<!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>
例:
頭部與底部延遲加載動(dòng)畫(huà)效果
$(document).ready(function() {
$('#header')
.css({ 'top':-50 })
.delay(1000)
.animate({'top': 0}, 800);
$('#footer')
.css({ 'bottom':-15 })
.delay(1000)
.animate({'bottom': 0}, 800);
});
- jQuery $.data()方法使用注意細(xì)節(jié)
- 實(shí)測(cè)jquery data()如何存值
- html5的自定義data-*屬性和jquery的data()方法的使用示例
- Jquery ajaxStart()與ajaxStop()方法(實(shí)例講解)
- jQuery中使用data()方法讀取HTML5自定義屬性data-*實(shí)例
- 理解jQuery stop()方法
- jQuery中data()方法用法實(shí)例
- jQuery中removeData()方法用法實(shí)例
- jquery中animate的stop()方法作用實(shí)例分析
- 逐一介紹Jquery data()、Jquery stop()、jquery delay()函數(shù)(詳)
相關(guān)文章
jQuery結(jié)合jQuery.cookie.js插件實(shí)現(xiàn)換膚功能示例
這篇文章主要介紹了jQuery結(jié)合jQuery.cookie.js插件實(shí)現(xiàn)換膚功能,結(jié)合實(shí)例形式分析了jQuery.cookie.js插件的常用函數(shù)功能及實(shí)現(xiàn)換膚功能的相關(guān)操作技巧,需要的朋友可以參考下2017-10-10
使用jQuery實(shí)現(xiàn)input數(shù)值增量和減量的方法
這篇文章主要介紹了使用jQuery實(shí)現(xiàn)input數(shù)值增量和減量的方法,實(shí)例分析了Bootstrap TouchSpin插件的用法,是非常實(shí)用的技巧,需要的朋友可以參考下2015-01-01
jQuery滿屏焦點(diǎn)圖左右滾動(dòng)特效代碼分享
這篇文章主要介紹了jQuery滿屏焦點(diǎn)圖左右滾動(dòng)特效,一段精致的焦點(diǎn)圖輪播代碼,有需要的小伙伴可以參考下。2015-09-09
jQuery實(shí)現(xiàn)可拖拽的許愿墻效果【附demo源碼下載】
這篇文章主要介紹了jQuery實(shí)現(xiàn)可拖拽的許愿墻效果,可實(shí)現(xiàn)拖拽圖片與層疊顯示功能,涉及jQuery插件的簡(jiǎn)單使用,并附帶demo源碼供讀者下載參考,需要的朋友可以參考下2016-09-09
jQuery實(shí)現(xiàn)獲取h1-h6標(biāo)題元素值的方法
這篇文章主要介紹了jQuery實(shí)現(xiàn)獲取h1-h6標(biāo)題元素值的方法,涉及$(":header")選擇器操作h1-h6元素及事件響應(yīng)相關(guān)技巧,需要的朋友可以參考下2017-03-03

