
- HTML Tutorial
- HTML - Home
- HTML - Overview
- HTML - Basic Tags
- HTML - Elements
- HTML - Attributes
- HTML - Formatting
- HTML - Phrase Tags
- HTML - Meta Tags
- HTML - Comments
- HTML - Images
- HTML - Tables
- HTML - Lists
- HTML - Text Links
- HTML - Image Links
- HTML - Email Links
- HTML - Frames
- HTML - Iframes
- HTML - Blocks
- HTML - Backgrounds
- HTML - Colors
- HTML - Fonts
- HTML - Forms
- HTML - Embed Multimedia
- HTML - Marquees
- HTML - Header
- HTML - Style Sheet
- HTML - Javascript
- HTML - Layouts
- HTML References
- HTML - Tags Reference
- HTML - Attributes Reference
- HTML - Events Reference
- HTML - Fonts Reference
- HTML - ASCII Codes
- ASCII Table Lookup
- HTML - Color Names
- HTML - Entities
- HTML - Fonts Ref
- HTML - Events Ref
- MIME Media Types
- HTML - URL Encoding
- Language ISO Codes
- HTML - Character Encodings
- HTML - Deprecated Tags
HTML defaultPrevented Event Property
The defaultPrevented event property in HTML is used to check whether the preventDefault() method was called or not. It returns a boolean value i.e. true if the preventDefault() method was called, else false.
Following is the syntax −
event.defaultPrevented
Let us now see an example to implement the defaultPrevented event property in HTML −
Example
<!DOCTYPE html> <html> <body> <h2>Demo Heading</h2> <a id="myid" href="https://example.com/">Demo (click me)</a> <script> document.getElementById("myid").addEventListener("click", function(event){ event.preventDefault() alert("Was preventDefault() called: " + event.defaultPrevented); }); </script> </body> </html>
Output
Click on the link and the following would get displayed in the alert box −
- Related Articles
- HTML returnValue Event Property
- HTML cancelable Event Property
- HTML currentTarget Event Property
- HTML isTrusted Event Property
- HTML view Event Property
- HTML DOM timeStamp Event Property
- HTML DOM Event type Property
- HTML DOM cancelable Event Property
- HTML ononline Event Attribute
- HTML onpageshow Event Attribute
- HTML ondragend Event Attribute
- HTML ondragenter Event Attribute
- HTML ondragleave Event Attribute
- HTML ondrop Event Attribute
- HTML ondragstart Event Attribute

Advertisements