Skip to content
Related Articles

Related Articles

Improve Article
Save Article
Like Article

HTML | DOM isEqualNode() Method

  • Last Updated : 25 Jul, 2019

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.



Parameters: The “othernode” parameter is required in this function.

Return Value: Returns a Boolean value, if matches then True else False.


<!DOCTYPE html>
        HTML | DOM isEqualNode() Method
    <!--script to check if nodes are equal-->
        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/>";
    <h3>Comparing the div elements.</h3>
    <!-- 3 div elements-->
    <button onclick="isequal()">Check</button>
    <p id="result"></p>

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

My Personal Notes arrow_drop_up
Recommended Articles
Page :

Start Your Coding Journey Now!