Comparing a DOM Node wih a DOM Element

后端 未结 1 467
谎友^
谎友^ 2021-01-21 08:24

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 DO

相关标签:
1条回答
  • 2021-01-21 09:08

    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
    }
    
    0 讨论(0)
提交回复
热议问题