- Trending Categories
Data Structure
Networking
RDBMS
Operating System
Java
iOS
HTML
CSS
Android
Python
C Programming
C++
C#
MongoDB
MySQL
Javascript
PHP
Physics
Chemistry
Biology
Mathematics
English
Economics
Psychology
Social Studies
Fashion Studies
Legal Studies
- Selected Reading
- UPSC IAS Exams Notes
- Developer's Best Practices
- Questions and Answers
- Effective Resume Writing
- HR Interview Questions
- Computer Glossary
- Who is Who
What e.preventDefault() method really does in jQuery?
The preventDefault() method stops the default action of a selected element from happening by a user. This method does not accept any parameter and works in two ways:
- It prevents a link from following the URL so that the browser can't go another page.
- It prevents a submit button from submitting a form.
Example
<html> <head> <script src="https://ajax.googleapis.com/ajax/libs/jquery/3.3.1/jquery.min.js"></script> <script> $(document).ready(function() { $("a").click(function(event) { event.preventDefault(); }); }); </script> </head> <body> <a href="https://www.tutorialspoint.com/">Tutorialspoint.com</a> <p>Click the link and it wont work.</p> </body> </html>
- Related Articles
- What does html() method do in jQuery?
- What does jQuery.andSelf( ) method do in jQuery?
- What does jQuery.children() method do in jQuery?
- What does jQuery.offset() method do in jQuery?
- What does jQuery.serialize() method do in jQuery?
- What does the method addFirst(E e) do in java?
- What does the method addLast(E e) do in java?
- What does the method addElement(E obj) do in java?
- What does the method add(E element) do in java?
- How does jQuery.filter() method work in jQuery?
- How does jQuery.find() method work in jQuery?
- How does jQuery.eq() method work in jQuery?
- How does jQuery.map() method work in jQuery?
- How does jQuery.slice() method work in jQuery?
- How does jQuery.nextAll() method work in jQuery?

Advertisements