Reset element to "default" event
Posted
by Channel72
on Stack Overflow
See other posts from Stack Overflow
or by Channel72
Published on 2010-05-25T00:50:51Z
Indexed on
2010/05/25
1:01 UTC
Read the original article
Hit count: 300
JavaScript
In Javascript, how can you set the event handler of a DOM element to default behavior?
For example, suppose I set the onkeypress
event of an input element:
elem.onkeypress = function() { alert("Key pressed!"); }
Later, how can I remove this event? Is it okay to simply set the onkeypress
property to null? I tried that and it works, but I don't know if it is the proper way to do this.
© Stack Overflow or respective owner