Reputation: 2681
I'm having some trouble figuring this problem out. I'm aware that everything in a DOM is a node and that a DOM element is also a node. However, my problem is this: I have a DOM node and a DOM element and I need to compare these to see if they are referring to the same element. Is that even possible? I think there is something fundamentally wrong with my question but can't figure out what it is. Thanks for your help.
Upvotes: 3
Views: 1846
Reputation:
Just do an ===
comparison. Since they're both objects, the comparison will be identity based.
if (my_node === my_element) {
// they're the same thing
}
Upvotes: 4