C
Csaba Gabor
Is there a way to remove an anonymous event handler that I attached
using attachEventListener? Or to say it another way, is there a way to
remove all event handlers that have been attached to an element?
Consider the html / script below. After attaching the onClick handler
to the div, I'd like to remove it. Perhaps there is a way to query the
div for all its handlers?
Thanks,
Csaba Gabor from Vienna
<div id=testdiv style="border:1px solid blue">Click me</div>
<script type='text/javascript'>
var div=document.getElementById('testdiv');
div.addEventListener("click",
function() {alert("I've been clicked")}, false);
div.removeEventListener("click", div.onClick, false);
</script>
using attachEventListener? Or to say it another way, is there a way to
remove all event handlers that have been attached to an element?
Consider the html / script below. After attaching the onClick handler
to the div, I'd like to remove it. Perhaps there is a way to query the
div for all its handlers?
Thanks,
Csaba Gabor from Vienna
<div id=testdiv style="border:1px solid blue">Click me</div>
<script type='text/javascript'>
var div=document.getElementById('testdiv');
div.addEventListener("click",
function() {alert("I've been clicked")}, false);
div.removeEventListener("click", div.onClick, false);
</script>