How can I prevent the default action of an event in jQuery

To prevent the default action of an event in jQuery, you can use the `event.preventDefault()` method. This is especially useful in situations where you want to stop the default behavior of elements like links or form submissions.

In the example below, clicking on a link prevents the default action of navigating to another page:

$(document).ready(function(){ $("a").click(function(event){ event.preventDefault(); // Prevent the default action alert("Default action prevented!"); }); });

jQuery prevent default event handling JavaScript web development