This page is Almost Ready

Notice: The WebPlatform project, supported by various stewards between 2012 and 2015, has been discontinued. This site is now available on github.

preventDefault

Summary

Cancels the default action of an event, if possible.

Method of dom/Eventdom/Event

Syntax

 event.preventDefault();

Return Value

No return value

Usage

 Use this method to prevent the default action of a cancelable event. For example, prevent the browser from navigating when clicking on a a element.

An event is cancelable if its cancelable property returns true.

Notes

If the event cannot be canceled, this method has no effect.

Related specifications

DOM Level 3 Events
Working Draft

See also

Related pages

Attributions