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 tooltip plugin


Tooltips are a popular way to show additional information to the user about the UI they are using. This recipe will show you how to create your own basic tooltip plugin that you can easily use in all of your projects.

Getting ready

Copy the jquery.plugin-template.js file and create jquery.tooltip.js, which will become the plugin file for this recipe. Create recipe-2.html and recipe-2.js in the same directory as the plugin file and the jQuery library.

How to do it…

To create a simple tooltip plugin and sample web page, perform the following steps:

  1. Add the following HTML to recipe-2.html to create a very simple web page with elements that can have a tooltip:

    <!DOCTYPE html>
    <html>
    <head>
        <title>Chapter 8 :: Recipe 2</title>
        <script src="jquery.min.js"></script>
        <script src="jquery.tooltip.js"></script>
        <script src="recipe-2.js"></script>
    </head>
    <body>
    <p><input type=...