[jQuery 核心-数据缓存] queue(callback)

在匹配的元素的队列最后添加一个函数。

返回值
jQuery

参数
name (String) :队列名,默认为fx

callback (Function) : 要添加进队列的函数

示例
插入一个自定义函数 如果函数执行后要继续队列,则执行 jQuery(this).dequeue();

HTML 代码:[code]
div { margin:3px; width:40px; height:40px;
position:absolute; left:0px; top:30px;
background:green; display:none; }
div.newcolor { background:blue; }

Click here…

[/code]jQuery 代码:[code]$(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(); });[/code]