1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22
| <script>
$(function(){
// exemple pour <input id="btn" type="button" value="Appliquer" />
var a = $("#btn");
var b = $("#btn");
// on compare les objets jQuery
console.log("a = " + a, ", b = " + b, ", a == b : " + (a == b), ", a === b : " + (a === b));
// a = [object Object] , b = [object Object] , a == b : false , a === b : false
// on compare le contenu des objets jQuery
// FAQ jQuery : Quelle différence y a-t-il entre $(...)[0] et $(...).eq(0) ?
// http://javascript.developpez.com/faq/jquery/?page=DOM#SelecteurDifference
console.log("a[0] = " + a[0], ", b[0] = " + b[0], ", a[0] == b[0] : " + (a[0] == b[0]), ", a[0] === b[0] : " + (a[0] === b[0]));
// a[0] = [object HTMLInputElement] , b[0] = [object HTMLInputElement] , a[0] == b[0] : true , a[0] === b[0] : true
});
</script> |
Partager