Book Image

jQuery 2.0 Development Cookbook

By : Leon Revill
Book Image

jQuery 2.0 Development Cookbook

By: Leon Revill

Overview of this book

Table of Contents (17 chapters)
jQuery 2.0 Development Cookbook
Credits
About the Author
About the Reviewers
www.PacktPub.com
Preface
Index

Preventing event triggers


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.

Getting ready

Create a blank HTML file named recipe-9.html and ensure that the latest version of the jQuery library is available.

How to do it…

Understand how to prevent default browser actions by performing the following steps:

  1. 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">&lt...