jQuery event.preventDefault() Method

Last Updated:

jQuery event.preventDefault() Method

The jQuery event.preventDefault() method stops the default action of an element from happening.

Note: This method does not accept any arguments.

Example

HTML Editor
<!DOCTYPE html> <html lang="en-US"> <head> <script src="https://ajax.googleapis.com/ajax/libs/jquery/3.5.1/jquery.min.js"></script> </head> <body> <h1>jQuery event.preventDefault() Method</h1> <a href="/css">Learn CSS</a> <script> $(document).ready(function(){ $("a").click(function(e){ e.preventDefault(); }); }); </script> </body> </html>

Syntax

event.preventDefault();

Browser Support

Devicedesktopmobile
Browsergoogle chromesafarifirefoxinternet Exploreredgeoperagoogle chromesafarifirefoxedgeoperaandroid webviewsamsung internet
event.preventDefault()YesYesYesYesYesYesYesYesYesYesYesYesYes

Share this Page

Meet the Author