1

我正在尝试制作一个 if 语句,是否需要两个参数才能加载函数,否则应该什么都不会发生。

这里它说form = false OR question.length == 0。但我不需要这个或这个。

查询:

if (form == false || questions.length == 0 ) { 
    alert("You need to create at least one question to create a "+moduleName); 
} else { 
    //do something 
}

它是如何完成的?

4

4 回答 4

3

逻辑或是|| _ .

逻辑and&&

if (form == false && questions.length == 0 ) { 
    alert("You need to create at least one question to create a "+moduleName); 
} else { 
    //do something 
}
于 2013-05-20T16:34:20.113 回答
3
if (form == false && questions.length == 0 ) { 
    alert("You need to create at least one question to create a "+moduleName); 
} else { 
    //do something 
}

教程

于 2013-05-20T16:35:13.193 回答
2

对 Javascript 中的 AND 子句使用双与号 (&&):

if (form == false && questions.length == 0 ) { 
   alert("You need to create at least one question to create a "+
} else { 
   //do something 
}
于 2013-05-20T16:35:53.813 回答
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 
}
于 2013-05-20T16:34:18.790 回答