 
  Data Structure Data Structure
 Networking Networking
 RDBMS RDBMS
 Operating System Operating System
 Java Java
 MS Excel MS Excel
 iOS iOS
 HTML HTML
 CSS CSS
 Android Android
 Python Python
 C Programming C Programming
 C++ C++
 C# C#
 MongoDB MongoDB
 MySQL MySQL
 Javascript Javascript
 PHP 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 −

Advertisements
 