jQuery

實(shí)例;事件;性能;移動(dòng);基礎(chǔ)

dequeue

英 [d?k'ju:]? ?美 [d?k'ju:]??

v.出列

jquery jQuery.dequeue() 方法 語法

作用:dequeue() 方法為匹配元素執(zhí)行序列中的下一個(gè)函數(shù)。這是底層級(jí)的方法;使用?.dequeue()?更加方便。

語法:.dequeue(queueName)

參數(shù):

參數(shù)描述
queueName? ??可選。字符串值,包含序列的名稱。默認(rèn)是 fx, 標(biāo)準(zhǔn)的效果序列。

說明:當(dāng)調(diào)用 .dequeue() 時(shí),會(huì)從序列中刪除下一個(gè)函數(shù),然后執(zhí)行它。該函數(shù)反過來會(huì)(直接或間接地)引發(fā)對(duì) .dequeue() 的調(diào)用,這樣序列才能繼續(xù)下去。

jquery jQuery.dequeue() 方法 示例

<!DOCTYPE html>
<html>
<head>
  <style>
    div { margin:3px; width:50px; position:absolute;
    height:50px; left:10px; top:30px; 
    background-color:yellow; }
    div.red { background-color:red; }  
  </style>

  <script type="text/javascript" src="http://apps.bdimg.com/libs/jquery/2.1.1/jquery.min.js"></script>
</head>

<body>

<button>開始</button>
<div></div>
<script>
$("button").click(function () {
  $("div").animate({left:'+=200px'}, 2000);
  $("div").animate({top:'0px'}, 600);
  $("div").queue(function () {
    $(this).toggleClass("red");
    $(this).dequeue();
  });
  $("div").animate({left:'10px', top:'30px'}, 700);
});
</script>

</body>
</html>
運(yùn)行實(shí)例 ?

點(diǎn)擊 "運(yùn)行實(shí)例" 按鈕查看在線實(shí)例