Latest web development tutorials

HTML DOM isEqualNode method

Elements Object Reference Element object

Examples

List items detected two different lists are equal:

var item1=document.getElementById("myList1").firstChild;
var item2=document.getElementById("myList2").firstChild;
item1.isEqualNode(item2);

Output:

false

try it"

Definition and Usage

isEqualNode () method is used to check whether two nodes are equal.

If the following conditions are satisfied on two nodes are equal and return true:

  • With the same node type
  • The same node name, node value, the local name, namespace URI and prefix.
  • With all their descendants have the same child node
  • It has the same attributes and attribute values ​​(attribute is not the same sort of way)

Tip: Use isSameNode () method to determine whether two nodes are identical.


Browser Support

Internet ExplorerFirefoxOperaGoogle ChromeSafari

All major browsers support isEqualNode () method

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


grammar

node.isEqualNode(node)

parameter

参数 类型 描述
node 节点对象 必须。比较的两个节点。

return value

类型 描述
Boolean 如果两个节点相同返回 true, 否则返回false。

technical details

DOM version Core Level 3 Node Object


Elements Object Reference Element object