VOOZH about

URL: https://www.geeksforgeeks.org/javascript/preventdefault-event-method/

⇱ preventDefault() Event Method - GeeksforGeeks


  • Courses
  • Tutorials
  • Interview Prep

preventDefault() Event Method

Last Updated : 11 Jul, 2025

The preventDefault() method is used to prevent the browser from executing the default action of the selected element. It can prevent the user from processing the request by clicking the link.

Syntax:

event.preventDefault()

Parameters:

It does not accept any parameter. The event is used to denote the event or action by the user in the response to which the method works.

Example: This code will prevent the browser from going to another page.

Output:

Example: This code will prevent the browser from redirecting the page to another PHP file.

Output:

Comment
Article Tags:
Article Tags: