我正在尝试制作一个if语句,需要两个参数来加载函数,否则应该没有任何反应。
这里它表示form = false或者question.length == 0.但我不需要这个或者这个。
Jquery:
if (form == false || questions.length == 0 ) {
alert("You need to create at least one question to create a "+moduleName);
} else {
//do something
}
怎么做?
答案 0 :(得分:3)
逻辑或是 || 。
逻辑和是&& 。
if (form == false && questions.length == 0 ) {
alert("You need to create at least one question to create a "+moduleName);
} else {
//do something
}
答案 1 :(得分:3)
if (form == false && questions.length == 0 ) {
alert("You need to create at least one question to create a "+moduleName);
} else {
//do something
}
答案 2 :(得分:2)
在Javascript中使用双&符号(&&)作为AND子句:
if (form == false && questions.length == 0 ) {
alert("You need to create at least one question to create a "+
} else {
//do something
}
答案 3 :(得分:1)
将OR更改为AND -
if (form == false && questions.length == 0 ) {
alert("You need to create at least one question to create a "+moduleName);
} else {
//do something
}