【发布时间】:2011-06-10 04:56:21
【问题描述】:
有人可以帮我处理“if else 语句”吗,我遇到了这个脚本的问题:
$('div#wrapper div.teamwrapper:odd').addClass('odd');
$('div.teamwrapper').each(function(index){
if($('div.teamwrapper').hasClass('odd')){
$(this).css('top', index*35);
}else{
$(this).css('top', index*28);
}
});
我的问题是,上面的脚本只执行“if语句”中的参数。即使对象没有“奇数”类,它也会将“if 语句”中的参数应用于所有“div.teamwrapper”。谢谢。
【问题讨论】:
-
你试过alert(),每个'if'和'else'!!
-
console.log会更好,alert 真的不应该再用了。
标签: jquery if-statement