我在一个页面上有两组 boxex。10 个属于“boxOne”类的盒子和另外 10 个属于“boxTwo”类的盒子
有一个按钮。单击按钮时,我使用 jquery 效果突出显示然后淡化属于类“Boxone”和“Boxtwo”的所有元素的背景颜色。
下面是代码。
var colorOfBox1 = "'" + $(.boxOne).css('backgroundColor') + "'";
$(.boxOne).animate(
{ 'backgroundColor': "#FF9900" },
{ 'queue': false, 'duration': 1000 });
setTimeout( function(){
$(.boxOne).animate(
{ 'backgroundColor': colorOfBox1},
{'queue': false, 'duration': 2000}
);
}, 2000);
var colorOfBox2 = "'" + $(".boxTwo).css("backgroundColor") + "'";
$('.boxTwo').animate({ 'backgroundColor': "#FF9900" }, {'queue': false, 'duration': 1000});
setTimeout(
function(){
$('.boxTwo).animate(
{ 'backgroundColor': colorOfBox2 },
{'queue': false, 'duration': 2000}
);
}, 2000);
单击按钮时,所有框都以指定的颜色突出显示。现在的问题是,有时这些框中的一些框不会淡出。他们的背景仍然突出。有时会发生这种情况并没有一致性。我想要一个一致的行为。
我看到 setTimeOut() 函数并没有统一应用于属于该类的所有元素......它只适用于少数元素......我犯了什么错误
?