我有一张关于城市的信息表。当温度低于32且高程大于1000时,我试图得到一个图像(在div内)。
我的陈述不断出现错误。
$("td.condition").each(function(){
if($("td.elevation").text() > 1000) && ($("td.high_temp").text() < 32)));
}
$(".ice").show();
});
答案 0 :(得分:1)
这是一个非常破碎的结构:
$("td.condition").each(function(){
if($("td.elevation").text() > 1000) && ($("td.high_temp").text() < 32)));
// The above is an empty "if" because of the semi-colon after it.
// So it checks the condition, but then doesn't do anything.
}
// Now the anonymous function is closed.
$(".ice").show();
// Which means the above line of code is trying to be passed as an argument to each(), which doesn't make sense.
});
// Then you have a stray } and then close the call to each()
如果对.show()
的调用应该在if
块内,那么你想把它放在if
之后的大括号块中:
$("td.condition").each(function(){
if($("td.elevation").text() > 1000) && ($("td.high_temp").text() < 32))) {
$(".ice").show();
}
});