preventDefault

The preventDefault JS Event if invoked when the cancelable attribute value is true, and while executing a listener for the event with passive set to false, signals to the operation that caused event to be dispatched that it needs to be canceled.

Syntax

event.preventDefault()

Examples

1 · dispatch · false

2 · dispatch · true

3 · button · false

4 · button · false

5 · button · true

6 · input · false

7 · input · false

8 · input · true

bubbles

cancelable

composed

composedPath

currentTarget

defaultPrevented

Event

eventPhase

isTrusted

stopImmediatePropagation

stopPropagation

target

timeStamp

type

Web Hypertext Application Technology Working Group (WHATWG)

Home Menu