preventDefault
Summary
Cancels the default action of an event, if possible.
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
- SVGZoomEventSVGZoomEvent
- BeforeUnloadEventBeforeUnloadEvent
- CompositionEventCompositionEvent
- CustomEventCustomEvent
- DragEventDragEvent
- EventEvent
- FocusEventFocusEvent
- KeyboardEventKeyboardEvent
- MessageEventMessageEvent
- MouseEventMouseEvent
- WheelEventWheelEvent
- MutationEventMutationEvent
- StorageEventStorageEvent
- TextEventTextEvent
- UIEventUIEvent
Attributions
Microsoft Developer Network: [Windows Internet Explorer API reference Article]