這是一個很破的結構:
$("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