We would like to know how to remove DOM Event Observer.
<!DOCTYPE html>
<html>
<body>
<div style="border: 1px solid red">
<!-- w w w . j a v a 2s. c o m-->
<div id="tt" style="border: 1px solid blue; color: red">Click me</div>
</div>
<script type='text/javascript'>
var foo = document.getElementById("tt");
foo.addEventListener("click",function(){
console.log(1);
var fee = foo.cloneNode();
foo.parentNode.replaceChild(fee, foo);
});
</script>
</body>
</html>
The code above is rendered as follows: