

- Trending Categories
Data Structure
Networking
RDBMS
Operating System
Java
iOS
HTML
CSS
Android
Python
C Programming
C++
C#
MongoDB
MySQL
Javascript
PHP
- Selected Reading
- UPSC IAS Exams Notes
- Developer's Best Practices
- Questions and Answers
- Effective Resume Writing
- HR Interview Questions
- Computer Glossary
- Who is Who
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 Questions & Answers
- HTML cancelable Event Property
- HTML currentTarget Event Property
- HTML returnValue Event Property
- HTML isTrusted Event Property
- HTML view Event Property
- HTML DOM cancelable Event Property
- HTML DOM timeStamp Event Property
- HTML DOM Event type Property
- HTML DOM PageTransition Event
- HTML DOM Clipboard event
- HTML DOM Storage Event
- HTML DOM touchcancel Event
- HTML DOM touchend Event
- HTML DOM touchmove Event
- HTML DOM touchstart Event
Advertisements