Latest web development tutorials
 

defaultPrevented Event Property

< Event Object

Example

Prevent a link from opening the URL, and check if preventDefault() was called:

document.getElementById("myAnchor").addEventListener("click", function(event){
    event.preventDefault()
    alert("Was preventDefault() called: " + event.defaultPrevented);
});
Try it Yourself »

Definition and Usage

The defaultPrevented event property checks whether the preventDefault() method was called for the event.


Browser Support

The numbers in the table specify the first browser version that fully supports the property.

Property
defaultPrevented 18.0 9.0 6.0 5.0 11.0

Syntax

event.defaultPrevented

Technical Details

Return Value: A Boolean, indicating whether the preventDefault() method was called for the event.

Possible values:

  • true - The preventDefault() method was called for the event
  • false - The preventDefault() method was not called for the event
DOM Version: DOM Level 3 Events

< Event Object