We would like to know how to assign null to onclick and re-add event handler.
<!DOCTYPE html>
<html>
<head>
<script type='text/javascript'>
window.onload=function(){<!-- www . java 2 s . c o m-->
document.getElementById('clickme').onclick = null;
document.getElementById('clickme').onclick = function(){
console.log('clicked');
};
}
</script>
</head>
<body>
<div id="clickme">Click me</div>
</body>
</html>
The code above is rendered as follows: