Jquery method to determine equality: 1. Use the "if (a==b && a==c && a==d) {}" method to determine; 2. Use "$(this). data("lastClick")" method can be used to realize the judgment.
The operating environment of this tutorial: windows7 system, jquery1.10.0 version. This method is suitable for all brands of computers.
Recommended: "jquery video tutorial"
Jquery method to determine whether they are equal:
Judge whether two strings are equal Equality:
Use identity (===) to judge (the value and type are consistent). If you use equality (==) to judge (the values are consistent), there will be a misjudgment.
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'); }
Judgement Whether two objects are equal:
html: <a href="#" id="a">a</a> <a href="#" id="b">b</a> <script type="text/javascript"> $(function(){ $('#a').greenify(); }); </script> js: $.fn.greenify = function() { console.log(this.index()); console.log($("#b").index()); this.css( "color", "green" ); };
In this case, the first method can be judged by index().
The second method is to add a data attribute to the object for judgment.
$(this).data("lastClick")
The above is the detailed content of How to determine whether jquery is equal. For more information, please follow other related articles on the PHP Chinese website!