XML DOM preventDefault() Method

Definition and Usage

The preventDefault() method cancels the default action of the event.

Syntax

event.preventDefault()

Description

This method notifies the web browser not to execute the default action associated with the event (if such an action exists). For example, if the type attribute is "submit", any event handler can be called at any stage of event propagation, and by calling this method, the submission of the form can be prevented. Note that if the cancelable attribute of the Event object is false, there is no default action, or the default action cannot be prevented. In either case, calling this method has no effect.