JavaScript: DOM Events

By Xah Lee. Date:

this page is a short intro on DOM event object. For basics of how to use event, see:

event Properties

Methods

write about stopPropagation

button.addEventListener ("click", function(e){
e.stopPropagation();
/* ... */
}, false);

write about stopPropagation

ou can prevent the default action with the preventDefault() function on the event object. Alternatively, you can just return false from the handler:

form.addEventListener ("submit", function(e){
/* ... */
return confirm("Are you super sure?");
}, false);

If the call to confirm() returns false—


write about The Event Object

when a event is fired, its event handler is passed a event object.

modern browsers support this object, except IE8 and below

methods

keyboard event Properties

Elements associated with the event:

JS in Depth
XAH  BUY NOW