Reading about jQuery objects from here, it states that all jQuery objects are unique, even if they that "This is true even if the object was created with the same selector or contain references to the exact same DOM elements."
So for example, the following would equate to false
:
$( "#logo" ) === $( "#logo" )
Why are jQuery objects all unique?
Thanks
Because, essentially, jQuery is using the factory pattern which creates a new instance of a jQuery object from a selector each time you call it.
As these are different instances, they are not equal.
Try following:
$( "#logo" ).get(0) === $( "#logo" ).get(0)
As far as I know this compares the original Javascript-DOM-Object like you get with e.g.
document.getElementById( "logo" ) === document.getElementById( "logo" )
If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With