Home > Web Front-end > JS Tutorial > body text

jquery determines whether values ​​are equal

藏色散人
Release: 2022-12-30 11:13:41
Original
4373 people have browsed it

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.

jquery determines whether values ​​are equal

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
Copy after login

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!

Related labels:
source:php.cn
Statement of this Website
The content of this article is voluntarily contributed by netizens, and the copyright belongs to the original author. This site does not assume corresponding legal responsibility. If you find any content suspected of plagiarism or infringement, please contact admin@php.cn
Popular Tutorials
More>
Latest Downloads
More>
Web Effects
Website Source Code
Website Materials
Front End Template
About us Disclaimer Sitemap
php.cn:Public welfare online PHP training,Help PHP learners grow quickly!