Javascript DOM HTML Node isSameNode()
Method
const isSameNode = node.isSameNode(otherNode)
Parameters
otherNode
- The Node to test against.<!DOCTYPE html> <html> <body> <div>This is the first element.</div> <div>This is the second element.</div> <div>This is the first element.</div> <p id="output"></p> <script> let output = document.getElementById("output"); let divList = document.getElementsByTagName("div"); output.innerHTML += "div 0 same as div 0: " + divList[0].isSameNode(divList[0]) + "<br/>"; output.innerHTML += "div 0 same as div 1: " + divList[0].isSameNode(divList[1]) + "<br/>"; output.innerHTML += "div 0 same as div 2: " + divList[0].isSameNode(divList[2]) + "<br/>"; </script>//from w ww . j ava 2s .co m </body> </html>