HTML | DOM isEqualNode() Method
The isEqualNode() method checks whether the two nodes are equal or not. These nodes are considered equal if they are of the same type, having the same characteristics and the same attributes. The attributes do not have to be in the same order.
Syntax:
node.isEqualNode(othernode)
Parameters: The “othernode” parameter is required in this function.
Return Value: Returns a Boolean value, if matches then True else False.
Example:
<!DOCTYPE html> <html> <head> <title> HTML | DOM isEqualNode() Method </title> <!--script to check if nodes are equal--> <script> function isequal() { var out = document.getElementById("result"); var divele = document.getElementsByTagName("div"); out.innerHTML += "element 1 equals element 1: " + divele[0].isEqualNode(divele[0]) + "<br/>"; out.innerHTML += "element 1 equals element 2: " + divele[0].isEqualNode(divele[1]) + "<br/>"; out.innerHTML += "element 1 equals element 3: " + divele[0].isEqualNode(divele[2]) + "<br/>"; } </script> </head> <body> <h3>Comparing the div elements.</h3> <!-- 3 div elements--> <div>GeeksforGeeks</div> <div>GfG</div> <div>GeeksforGeeks</div> <button onclick="isequal()">Check</button> <p id="result"></p> </body> </html> |
Output:
Before clicking on the Check button:

After clicking on the Check button:

Supported Browsers: The browser supported by DOM isEqualNode() Method are listed below:
- Google Chrome
- Firefox
- Opera
- INternet Explorer
- Safari
Recommended Posts:
- HTML | DOM contains() Method
- HTML | DOM createElement() Method
- HTML | DOM Select add Method
- HTML | DOM removeAttributeNode() Method
- HTML | DOM hasChildNodes() Method
- HTML | DOM scrollIntoView() Method
- HTML | DOM importNode() Method
- HTML | DOM removeChild() Method
- HTML | DOM writeln() Method
- HTML | DOM normalizeDocument() Method
- HTML | DOM click() Method
- HTML | DOM exitFullscreen() Method
- HTML | DOM cloneNode() Method
- HTML | DOM isSameNode() Method
- HTML | DOM createTextNode() Method
If you like GeeksforGeeks and would like to contribute, you can also write an article using contribute.geeksforgeeks.org or mail your article to contribute@geeksforgeeks.org. See your article appearing on the GeeksforGeeks main page and help other Geeks.
Please Improve this article if you find anything incorrect by clicking on the "Improve Article" button below.

