English | 简体中文 | 繁體中文 | Русский язык | Français | Español | Português | Deutsch | 日本語 | 한국어 | Italiano | بالعربية
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.
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‹/›
isSameNode() method is fully supported by all browsers:
Method | |||||
isSameNode() | Yes | Not Supported | Yes | Yes | Yes |
Parameter | Description |
---|---|
node | The node you want to compare with the specified node |
Return Value: | A boolean value, returns true if the two nodes are the same, otherwise returns false |
---|---|
DOM Version: | DOM Level3 |
HTML DOM Reference:node.isEqualNode() method