I have some result like this:
1. //node, root are "native" dom object from getElementById and alike
2. $(node)[0] == node //true
3. $(root)[0] == root //true
4. node.parentNode.parentNode == root //true
5. $(node).parent().parent()[0] == $(root)[0] //true
6. $(node).parent().parent() == $(root) //false
I want to write some code like line 6, which doesn’t work. So I have to use line 5 instead.Why doesn’t line 6 work?
To my knowledge, jQuery dom is the container/wrapper of “native” dom. May anyone explain the details or recommend reference?
There is only one DOM.
But when you build
$(domObject)you’re making a new jquery object encapsulating a dom object.There is no reason for this object to be equal to another
$(domObject)even if the domObject is the same.Look at it like this :
new ProxyObject(a) == new ProxyObject(a)would return false becausenew ProxyObjectbuilds an object. That’s the same problem with the prettier syntax of jQuery.