我有两个行动,我需要应用到一组DIV,但我需要一个周期发生在另一个是结束。
这是我的代码:
$("div").each(function(){
//do stuff first
}).each(function(){
//do stuff next
});但目前,do stuff next发生在do stuff first完成之前。我能做些什么阻止这一切吗?
全脚本
$("div").each(function(){
if($(this).html() === "yes"){
$(this).fadeOut(time,function(){
$(this).parent().height(0);
});
}
}).each(function(){
if($(this).html() !== "yes"){
$(this).parent().height(25);
$(this).fadeIn(time);
}
});发布于 2011-08-07 22:07:32
知道你想要fadeIn,然后设置高度,这会做你所需要的吗?
var divs = $('div');
divs.fadeIn(function () {
divs.height('200');
});使用每个设置为不同的div允许不同的设置:
$('div').each(function () {
var div = $(this), toggle = true;
div.fadeIn(function () {
if (toggle = !toggle) {
div.height('200');
} else {
div.width('200');
}
});
});看到你的代码片段,我想我现在明白了:
var yesDivs = $('div').filter(function () {
return $(this).html() === 'yes';
});
yesDivs.fadeOut(time, function () {
yesDivs.parent().height(0);
$('div').filter(function () {
return $(this).html() !== 'yes';
}).fadeIn(time).parent().height(25);
});https://stackoverflow.com/questions/6976086
复制相似问题