要利用你的僞代碼:
if this.ewCount != 0 then {}
elseif NotDoneh == 0 then {}
ELSE {}
,並把它轉換成JavaScript:
if (this.ewCount != 0) {
// do something
} else if (NotDoneh == 0) {
// do something else
} else {
// do something else again
}
在您的實際JS有幾個問題,主要是你已經有了月底+操作一些行之後沒有另一個操作員,並且你已經關閉了你的每條if語句});
,他們應該剛好有}
- 我想你已經混淆瞭如何關閉$.each
,因爲它是一個函數作爲參數調用,因此它需要爲$.each(items,function() { });
。
我不知道如何重寫你的JS,因爲它有一個if (DoneWidth == 0)
測試不在你的僞代碼 - 是否應該嵌套在第一個如果,或...?無論如何,如果你更新它看起來像下面至少應該是有效的,即使不是正確的算法:
$.each(items, function() {
if (this.ewCount != 0) {
// note the following if is nested inside the one above: not sure
// if that's what you intended, but it gives a good example of
// how to do something like that
if (DoneWidth == 0) {
conta += '<br/>dddddddddddddddddd<br/><br/>';
}
} else if (NotDoneh == 0) {
conta += '<br/>dddddddddddddddddd<br/><br/>';
} else {
// you don't seem to have any code to go in the final else,
// unless it was meant to be
container += '</div>';
}
container += '</div>';
}); // note here }); is correct because the } closes the anonymous function
// and then the); finishes off the $.each(...
你可以把連同的if/else結構我上面顯示,和/或者以其他方式移動東西,這樣右邊的代碼就會在右邊的內部結束。
'+' - 操作員需要2個項目。你只給一個。 conta + =「one」+它應該像conta + =「one」或conta + =「one」+「two」 –
poitroae
2011-12-17 10:58:58