反转if语句

时间:2016-09-08 14:23:40

标签: javascript if-statement conditional-statements

我理解if条件是如何工作的。像这样:

if (condition) {
    block of code to be executed if the condition is true
}

但我如何反转,例如如果声明正确,不要触发这行代码?

if $("span:contains('399')) {
    block of code to be executed if the condition is false
}

1 个答案:

答案 0 :(得分:0)

if (!condition) {
    block of code to be executed if the condition is false
}
相关问题