English | 简体中文 | 繁體中文 | Русский язык | Français | Español | Português | Deutsch | 日本語 | 한국어 | Italiano | بالعربية
isEqualNode()method tests whether two nodes are equal.
If all of the following conditions are met, the two nodes are equal:
they have the same node type
they have the same nodeName, NodeValue, localName, namespaceURI, and prefix
they have the same child nodes with all child nodes (childNodes)
they have the same attributes and attribute values (the order of attributes is not the same)
UsingisSameNode()method to determine whether two nodes are the same node.
node.isEqualNode(node)
let output = document.getElementById("output"); let divList = document.getElementsByTagName("div"); output.innerHTML +="div 0 equals div 0: " + divList[0].isEqualNode(divList[0]) + "<br>"; output.innerHTML +="div 0 equals div 1: " + divList[0].isEqualNode(divList[1]) + "<br>"; output.innerHTML +="div 0 equals div 2: " + divList[0].isEqualNode(divList[2]) + "<br>";Test and See‹/›
All browsers fully support the isEqualNode() method:
Method | |||||
isEqualNode() | Is | Is | Is | Is | Is |
Parameter | Description |
---|---|
node | The node to be compared for equality |
Return Value: | A boolean value, returns true if two nodes are equal, otherwise returns false |
---|---|
DOM Version: | DOM Level3 |
HTML DOM Reference:node.isSameNode() method