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

Triggering events manually


There may be parts of your web application where reacting to events fired by user interaction is not enough. jQuery allows us to manually trigger events from within our code.

Getting ready

When creating a web application, there may be times when you require a form that is handled solely by your jQuery code and is not submitted as a typical HTML form, perhaps to make an AJAX request instead. This is what we will demonstrate in this recipe. To get started, once again create another blank HTML document named recipe-8.html. Ensure that it is placed in an easily accessible location on your computer.

How to do it…

Learn how to manually trigger events from within JavaScript by performing the following steps:

  1. Add the following HTML code to recipe-8.html in order to create a very basic web page with a set of form elements and a submit button:

    <!DOCTYPE html>
    <html>
    <head>
        <title>Chapter 2 :: jQuery Events</title>
        <script src="jquery.min...