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

HTML DOM isEqualNode() method

HTML DOM Element Object

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.

Syntax:

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‹/›

Browser Compatibility

All browsers fully support the isEqualNode() method:

Method
isEqualNode()IsIsIsIsIs

Parameter Value

ParameterDescription
nodeThe node to be compared for equality

Technical Details

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

Related References

HTML DOM Reference:node.isSameNode() method

HTML DOM Element Object