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.
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.
Learn how to manually trigger events from within JavaScript by performing the following steps:
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...