日期:2014-05-16 浏览次数:20396 次
<body>
<ul id="mylist">
<li>Item 1</li>
<li>Item 2</li>
<li>Item 3</li>
</ul>
</body>
EventUtil.addHandler(window, "load", function(event) {
var list = document.getElementById("myList");
EventUtil.addHandler(document, "DOMSubtreeModified", function(event) {
alert(event.type);//DOMSubtreeModified
alert(event.target);//object HTMLHtmlElement
});
EventUtil.addHandler(document, "DOMNodeRemoved", function(event) {
alert(event.type);//DOMNodeRemoved
alert(event.target);//object HTMLDivElement
alert(event.relatedNode);//object HTMLHtmlElement
});
//###这里为什么不能直接指定节点<ul>(list)?###
EventUtil.addHandler(list.firstChild, "DOMNodeRemovedFromDocument", function(event) {
alert(event.type);//DOMNodeRemoved
alert(event.target);//object HTMLUListElement
alert(event.relatedNode);//object HTMLBodyElement
});
list.parentNode.removeChild(list);
});