I'm about to update my code to use addEventListener()
over just writing to the element property in Javascript.
Before I do this I wanted to verify a few things.
I'm assuming that I do not have to call
removeEventListener()
, if I update the DOM and remove the elements ( by.innerHTML
write ).addEventListener
is supported on the popular modern browsers - IE9, Chrome, Firefox, SafariThere are no other issues that might arise on modern browsers.
I'm asking because I don't want to jump the gun in updating my code.
Notes:
property to event correlations ( remove the on ).
- onkeypress - keypress
- onblur -> blur
- onfocus -> focus
Research
https://developer.mozilla.org/en/DOM/element.addEventListener ( Has compatibility Chart )
http://www.quirksmode.org/js/events_advanced.html
Related
JavaScript listener, "keypress" doesn't detect backspace?
Notes
- Instead of returning false. Use
preventDefault()
to stop forms from submitting on enter.