我在我的項目中使用了Wikipedia API。我循環一個對象來顯示下面的文章和它的描述。隱藏帶有未定義字符串的列表項目
大多數李(文章)顯示正常,但有些人的表現不確定。這樣
我要的是隱藏李 S的顯示不確定。我寫了代碼
// Check if some articles are undefined if so hide them
if (articleAuthor === "undefined") {
$('.articleItem').html('');
}
但它沒有幫助。 $('。articleItem')是動態創建列表項。
提前感謝!
你試過和'undefined'比較沒有引號嗎? 'undefined'是javascript中的一個對象 – niyasc
'if(articleAuthor ===「undefined」)'意思是'articleAuthor'等於'undefined',類型爲'string'。 –