There are many situations where a jQuery developer will want to prevent the default browser actions of events of normal HTML elements such as forms, buttons, or even their own event handlers. jQuery provides the ability to stop these events. This allows the developer to prevent situations such as multiple button clicks, multiple form submissions, and accidental submissions, or generally allow the developer to change the normal behavior of typical events.
Create a blank HTML file named recipe-9.html
and ensure that the latest version of the jQuery library is available.
Understand how to prevent default browser actions by performing the following steps:
Add the following HTML code to
recipe-9.html
; ensure that you update the reference to the jQuery library to the correct location on your computer:<!DOCTYPE html> <html> <head> <title>Chapter 2 :: jQuery Events</title> <script src="jquery.min.js"><...