Click here to Skip to main content
13,505,629 members
Click here to Skip to main content
Add your own
alternative version

Tagged as


3 bookmarked
Posted 6 Jan 2012

jQuery Tooltip

, 6 Jan 2012
Rate this:
Please Sign up or sign in to vote.
How to add a jQuery tooltip

In order to add a tooltip to any HTML element, you need to do the following:

  • Include the JavaScript and stylesheet files. The tooltip plug in is implemented in the jqxtooltip.js file.
    <link rel="stylesheet" 
    href="styles/jqx.base.css" type="text/css" />
    <script type="text/javascript" 
    <script type="text/javascript" 
    <script type="text/javascript" 
  • Add the HTML elements. You need to have two things: the elements that show a tooltip when the cursor is placed on top of them and one or many tooltip elements. In this setup, there is a single tooltip element with id=’jqxTooltip’ that works for all of the target elements (‘div1′ and ‘div2′):
    <div id='jqxTooltip'></div>
    <div id='div1' style='background: orange; 
    width: 10px; height: 10px;'></div>
    <div id='div2' style='background: blue; 
    margin-top: 20px; width: 10px; height: 10px;'></div>
  • Tooltip activation starts by selecting the tooltip element and calling the jqxTooltip constructor.

    Then, you need to call the tooltip’s ‘add’ function and supply two arguments to it – a jQuery selector to the tooltip target element and the tooltip title.

    $("#jqxTooltip").jqxTooltip('add', $('#div1'), 'Title1');
    $("#jqxTooltip").jqxTooltip('add', $('#div2'), 'Title2');

The default behaviour is that the tooltip is positioned on the bottom/right of the target element.

jquery tooltip


This article, along with any associated source code and files, is licensed under The Code Project Open License (CPOL)


About the Author

United States United States
This member doesn't quite have enough reputation to be able to display their biography and homepage.
Group type: Organisation

13 members

You may also be interested in...

Comments and Discussions

-- There are no messages in this forum --
Permalink | Advertise | Privacy | Terms of Use | Mobile
Web04 | 2.8.180417.1 | Last Updated 6 Jan 2012
Article Copyright 2012 by jqwidgets
Everything else Copyright © CodeProject, 1999-2018
Layout: fixed | fluid