How to use DOM Node isSameNode in JavaScript

In this article I am going to explain about DOM Node isSameNode() method in JavaScript.
  • 1875

JavaScript DOM Node isSameNode() Method

JavaScript isEqualNode() method use for check two node is same or not. If node are same then it will return true other wise it will return false.

Syntax

node.isSameNode(node)

Example

<html>

<head>

    <script type="text/javascript">

        function myfun() {

            var mm = document.getElementById("list");

            var hh = document.getElementsByTagName("UL")[0];

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

            x.innerHTML = mm.isSameNode(hh);

        }

    </script>

</head>

<body>

    <h1 id="tst" style="color: Blue">

    </h1>

    <ul id="list">

        <li>Apple</li><li>Mango</li></ul>

    <p>

        click button to check list element are same or not</p>

    <button onclick="myfun()">

        check</button>

</body>

</html>

 

Output

 

 isSame.jpg

 

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
 

Categories

More Articles

© 2020 DotNetHeaven. All rights reserved.