<html>
<body>
<button onclick="myFunction()">Try it</button>
<p id="demo">Click the buttons to check if the myList element is the same as the document's first list element.</p>
<ul id="myList"><li>Coffee</li><li>Tea</li></ul>
<script>
function myFunction()
{
var item1=document.getElementById("myList");
var item2=document.getElementsByTagName("UL")[0];
var x=document.getElementById("demo");
x.innerHTML=item1.isSameNode(item2);
}
</script>
<p><strong>Note:</strong> Firefox stopped supported this method as of version 10, Instead, use === to compare if two nodes are the same.</p>
<p><strong>Note:</strong> Internet Explorer 8 and earlier does not support the isSame method.</p>
</body>
</html>