Private archive copy · Unofficial site · Content copyright belongs to Runoob Tutorial and the original authors · View Original

HTML DOM isSameNode method

HTML DOM isSameNode() method

Element Object Reference Element object

Example

Check whether two nodes are the same node:

var item1=document.getElementById("myList1");

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

item1.isSameNode(item2);

Output result:

true

Try it »


Definition and Usage

The isSameNode() method returns true if a node is the same node as the given node, otherwise it returns false.

**Tip:** Use The isEqualNode() method checks whether two nodes are equal, but not necessarily the same node.


Browser support

Internet ExplorerFirefoxOperaGoogle ChromeSafari

All major browsers except Firefox support the isSameNode() method.

Note: Firefox has not supported the isSameNode method since version 10, because the method was deprecated after DOM 4; you can use === to compare two elements.

Note: Internet Explorer 8 and earlier IE versions do not support this method.


Syntax

node

.isSameNode(

node

)

Parameters

Parameters Type Description
node Node object Required. The node you want to compare.

Return Value

Type Description
Boolean Returns true if the two nodes are equal, otherwise returns false.

Technical Details

DOM version Core Level 3 Node Object

Element Object Reference Element object