?
This document uses PHP Chinese website manual Release
顯示或操作在匹配元素上執(zhí)行的函數(shù)隊列
element:檢查附加列隊的DOM元素
queueName:字符串值,包含序列的名稱。默認是 fx, 標準的效果序列。
element:檢查附加列隊的DOM元素
queueName:字符串值,包含序列的名稱。默認是 fx, 標準的效果序列。
newQueue:替換當前函數(shù)列隊內(nèi)容的數(shù)組
element:檢查附加列隊的DOM元素
queueName:字符串值,包含序列的名稱。默認是 fx, 標準的效果序列。
callback():要添加進隊列的函數(shù)
顯示隊列長度
<style> div { margin:3px; width:40px; height:40px; position:absolute; left:0px; top:30px; background:green; display:none; } div.newcolor { background:blue; } span { color:red; } </style> <button id="show">Show Length of Queue</button> <span></span> <div></div>
$("#show").click(function () { var n = $("div").queue("fx"); $("span").text("Queue length is: " + n.length); }); function runIt() { $("div").show("slow"); $("div").animate({left:'+=200'},2000); $("div").slideToggle(1000); $("div").slideToggle("fast"); $("div").animate({left:'-=200'},1500); $("div").hide("slow"); $("div").show(1200); $("div").slideUp("normal", runIt); } runIt();
通過設定隊列數(shù)組來刪除動畫隊列
<style> div { margin:3px; width:40px; height:40px; position:absolute; left:0px; top:30px; background:green; display:none; } div.newcolor { background:blue; } </style> <button id="start">Start</button> <button id="stop">Stop</button> <div></div>
$("#start").click(function () { $("div").show("slow"); $("div").animate({left:'+=200'},5000); $("div").queue(function () { $(this).addClass("newcolor"); $(this).dequeue(); }); $("div").animate({left:'-=200'},1500); $("div").queue(function () { $(this).removeClass("newcolor"); $(this).dequeue(); }); $("div").slideUp(); }); $("#stop").click(function () { $("div").queue("fx", []); $("div").stop(); });
插入一個自定義函數(shù) 如果函數(shù)執(zhí)行后要繼續(xù)隊列,則執(zhí)行 jQuery(this).dequeue();
<style> div { margin:3px; width:40px; height:40px; position:absolute; left:0px; top:30px; background:green; display:none; } div.newcolor { background:blue; } </style> Click here... <div></div>
$(document.body).click(function () { $("div").show("slow"); $("div").animate({left:'+=200'},2000); $("div").queue(function () { $(this).addClass("newcolor"); $(this).dequeue(); }); $("div").animate({left:'-=200'},500); $("div").queue(function () { $(this).removeClass("newcolor"); $(this).dequeue(); }); $("div").slideUp(); });