实例代码“Ctrl+/”提示“F11/ESC”全屏 返回 格式化 恢复 运行
x
 
1
<!DOCTYPE html>
2
<html>
3
<body>
4
<button onclick="myFunction('myList1','myList2')">Compare List 1 and 2</button>
5
<button onclick="myFunction('myList1','myList3')">Compare List 1 and 3</button>
6
7
<p id="demo">Click the buttons to compare the <em>first item</em> in two of the lists.</p>
8
9
List 1:
10
<ul id="myList1"><li>Water</li><li>Milk</li></ul>
11
List 2:
12
<ul id="myList2"><li>Coffee</li><li>Tea</li></ul>
13
List 3:
14
<ul id="myList3"><li>Water</li><li>Fire</li></ul>
15
16
<script>
17
function myFunction(x,y)
18
{
19
var item1=document.getElementById(x).firstChild;
20
var item2=document.getElementById(y).firstChild;
21
var x=document.getElementById("demo");
22
x.innerHTML=item1.isEqualNode(item2);
23
}
24
</script>
25
26
<p><strong>Note:</strong> Internet Explorer 8 and earlier does not support the isEqualNode method.</p>
27
28
</body>
29
</html>