我有這種情況,我需要在JavaScript函數中使用三個條件:和條件。javascript中的多個「AND」條件
我已經寫了這樣的代碼
if ((frm_add_announcement.sublink[0].checked == true)) {
if ((document.getElementById('captionurl').value.trim() == "") &&
(document.getElementById("captionfile").files.length == 0) &&
(document.getElementById('ifpresent').value != "1")) {
alert("Enter a url/upload a file");
//var alertmsg=document.getElementById("captionfile").value;
//alert(alertmsg);
document.getElementById('captionurl').focus();
return false;
}
}
但它不工作。有沒有控制檯錯誤
它是否在控制檯中發生錯誤? –
你應該逐一檢查每個條件。 –
@ KeesvanLierop-No ..沒有錯誤。 – Vimal