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

Creating a custom event


jQuery provides the developer with ways to handle built-in JavaScript events with functions such as .click(), .hover(), and others. jQuery also allows developers to create their own event types for additional functionality. With the creation of custom events, developers are also able to pass data around their application more easily.

Getting ready

Create another blank HTML document named recipe-10.html in an easily accessible location.

How to do it…

Learn how to create a custom event using jQuery by performing the following steps:

  1. Add the following HTML code to this newly created HTML document. Remember to update the reference to the jQuery library to point to its local location on your computer.

    <!DOCTYPE html>
    <html>
    <head>
        <title>Chapter 2 :: jQuery Events</title>
        <script src="jquery.min.js"></script>
        <script>
    
        </script>
    </head>
    <body>
        <button rel="green">Green</button>...