我刚刚写了一个小的 if, else if 循环,我unexpected token ';'在控制台中得到一个错误。如果我删除;每个$(this).css('top', top-3"em");语句之后,我会得到另一个错误,说}之前else if是意外的!
这是我的循环,有什么我可能误入歧途的想法吗?
$('div.result').each(function() {
$(this).css('top', top+"em");
top = top + 8;
resultcount = resultcount - 1;
if(resultcount=5) {
$(this).css('top', top-3"em");
} else if(resultcount=4) {
$(this).css('top', top-7"em");
} else if(resultcount=3) {
$(this).css('top', top-14"em");
} else if(resultcount=2) {
$(this).css('top', top-20"em");
} else(resultcount=1) {
$(this).css('top', top-30"em");
}
});