这是一个很破的结构:
$("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();
}
});
阅读错误将是一个很好的第一步。这看起来像是一个奇怪的混合语法错误。你有一个空的'if'块,然后关闭该函数,然后在关闭该函数后尝试使用更多代码,然后尝试再次关闭该函数*。 – David