Jquery method to determine whether values are equal: first create a code sample file; then define several different variables; finally use the comparison operator "==" or "===" to determine whether the variable values are equal That’s it.
The operating environment of this article: windows7 system, jquery1.2.6 version, Dell G3 computer.
jquery can use == or === to judge:
1. == is to judge whether the values are equal. If the data types are different, convert the data type first and then judge;
2. === is similar to ==. It also determines whether the values are equal. However, if you use ===, if the data types are different and the values are the same, they will not be equal.
Example:
var a = "1"; //字符串1 var b = 1; //数值1 var c = true; //布尔值1 var d = "1"; if (a==b && a==c && a==d) {console.log('equality');} //输出equality if (a===b || a===c) { //输出not identity console.log('identity'); } else { console.log('not identity'); } if (a===d) {console.log('identity');} //输出identity
Recommended: "jquery video tutorial"
The above is the detailed content of jquery determines whether values are equal. For more information, please follow other related articles on the PHP Chinese website!