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 ...

Get jQuery 2.0 Development Cookbook now with the O’Reilly learning platform.

O’Reilly members experience books, live events, courses curated by job role, and more from O’Reilly and nearly 200 top publishers.