将匹配元素的队列用新的一个队列来代替(函数数组).
返回值
jQuery
参数
name (String) :队列名,默认为fx
queue (Array) : 用于替换的队列。所有函数都有同一个参数,这个值与queue(callback)相同
示例
通过设定队列数组来删除动画队列
HTML 代码:[code]
div { margin:3px; width:40px; height:40px;
position:absolute; left:0px; top:30px;
background:green; display:none; }
div.newcolor { background:blue; }
Start
Stop
[/code]jQuery 代码:[code] $("#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();
});[/code]