欧美bbbwbbbw肥妇,免费乱码人妻系列日韩,一级黄片

jquery delay()介紹及使用指南

 更新時(shí)間:2014年09月02日 11:39:54   投稿:hebedich  
.delay()是用來在jQuery動(dòng)畫效果和類似隊(duì)列中是最好的。但是,由于其本身的限制,比如無法取消延時(shí)——.delay(),它不是JavaScript的原生 setTimeout函數(shù)的替代品,這可能是更適合某些使用情況。

delay(duration,[queueName])

設(shè)置一個(gè)延時(shí)來推遲執(zhí)行隊(duì)列中之后的項(xiàng)目。
jQuery 1.4新增。用于將隊(duì)列中的函數(shù)延時(shí)執(zhí)行。他既可以推遲動(dòng)畫隊(duì)列的執(zhí)行,也可以用于自定義隊(duì)列。

duration:延時(shí)時(shí)間,單位:毫秒

queueName:隊(duì)列名詞,默認(rèn)是Fx,動(dòng)畫隊(duì)列。

參數(shù) 描述
speed 可選。規(guī)定延遲的速度。

可能的值:

  • 毫秒
  • "slow"
  • "fast"
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)畫效果

$(document).ready(function() {
 $('#header')
 .css({ 'top':-50 })
 .delay(1000)
 .animate({'top': 0}, 800);

 $('#footer')
 .css({ 'bottom':-15 })
 .delay(1000)
 .animate({'bottom': 0}, 800); 
});

相關(guān)文章

最新評(píng)論