How to use DOM Node isEqualNode in JavaScript

In this article I am going to explain about DOM Node isEqualNode() Method in JavaScript
  • 2050

JavaScript DOM Node isEqualNode() Method

JavaScript isEqualNode() method use for check two node is equal or not. If node are equal then it will return true othaer wise false. Equal node have following condition.

  • Node type must be same.
  • Number of child node must be same.
  • They have same attribute.
  • They have same name, same value, same namespace.






    <script type="text/javascript">

        function myfun(x, y) {

            var item1 = document.getElementById(x).firstChild;

            var item2 = document.getElementById(y).firstChild;

            var x = document.getElementById("tst");

            x.innerHTML = item1.isEqualNode(item2);





    <h1 id="tst">


    First List:

    <ul id="l1">


    Second List:

    <ul id="l2">



        cleck button to check list item</p>

    <button onclick="myfun('l1','l2')">







Before click




After click



You may also want to read these related articles: here
Ask Your Question 
Got a programming related question? You may want to post your question here


More Articles

© 2020 DotNetHeaven. All rights reserved.