English | 简体中文 | 繁體中文 | Русский язык | Français | Español | Português | Deutsch | 日本語 | 한국어 | Italiano | بالعربية

HTML DOM isSameNode() Method

HTML DOM Element Object

isSameNode()The method tests whether two nodes are the same, i.e., they refer to the same object.

If two nodes are the same, the isSameNode() method returnstrue, otherwise returnsfalse.

UsageisEqualNode()The method checks if two nodes are equal.

Syntax:

node.isSameNode(node)
let output = document.getElementById("output");
let divList = document.getElementsByTagName("div");
output.innerHTML += "div 0 with div 0 same: " + divList[0].isSameNode(divList[0]) + "<br>";
output.innerHTML += "div 0 with div 1Same: " + divList[0].isSameNode(divList[1]) + "<br>";
output.innerHTML += "div 0 with div 2Same: " + divList[0].isSameNode(divList[2]) + "<br>";
Test See‹/›

Browser Compatibility

isSameNode() method is fully supported by all browsers:

Method
isSameNode()YesNot SupportedYesYesYes

Parameter Value

ParameterDescription
nodeThe node you want to compare with the specified node

Technical Details

Return Value:A boolean value, returns true if the two nodes are the same, otherwise returns false
DOM Version:DOM Level3

Related References

HTML DOM Reference:node.isEqualNode() method

HTML DOM Element Object