The isEqualNode()
returns true
if
two elements (or nodes) are equal.
element.isEqualNode(node)
or
node.isEqualNode(node)
Parameter | Description |
node |
Required. The node to compare. |
Type | Description |
Boolean |
true if the nodes are equal,
otherwise false .
|
<!DOCTYPE html>
<html>
<head>
<title>DOM Navigation</title>
</head>
<body>
<ul id="list-1">
<li class="abc">orange</li>
<li>Banana</li>
<li>Apple</li>
<li>Grapes</li>
</ul>
<ul id="list-2">
<li>Guava</li>
<li class="abc">orange</li>
<li>PineApple</li>
</ul>
<script src="js/dom-create.js"></script>
</body>
</html>
var target1 = document.getElementById("list-1").firstElementChild;
var target2 = document.getElementById("list-2").children[1];
var equal = target1.isEqualNode(target2);
console.log(equal);