Javascript Tooltip
Javascript Tooltip
is a box that appears following a client event, such as onmouseover, onclick, etc.-
Triggering Events
onmouseover, onclick, onfocus, ect.
It leaves to the triggering element to decide how to launch the tooltip:
<span onclick="tooltip.pop(this, 'Hello world!')"> Click me </span>
-
Accessible Content
The tooltip will stay when moving mouse from target element to tooltip. Example
It also has an option smartPosition. If set to true, when it finds there is no enough space to show, the tooltip box will reposition itself to make it always viewable.
-
Content Source Location
- can be specified directly in script
- or written into HTML element anywhere in the page
- or obtained from external documents or other web pages through Ajax
-
Closing Options
By default the tooltip box will close when the mouse left the target or the tooltip popup content.
If requiring the tooltip stay even if the mouse has left the target, you can use its sticky option. When it is set to true, it will have a close button ×, and the popup can only be closed by the button.
-
Cross-browser compatible
The tooltip works beautifully in every browser on any device:
IE 6.0+, Firefox 1.5+, Chrome 0.2+, Safari 3.0+, Opera 9.1+, Netscape 7.2+, and hand-held devices such as iPad, iPhone, android...
<a onclick="tooltip.pop(this,'Hello');">Hi</a>
An element on the page, such as <div id="div1">...(tooltip content)...</div> (div1 and its content will be used as the tooltip content):
<a onclick="tooltip.pop(this, '#div1');">Hi</a>
Usually those elements are placed inside a display:none wrapper:<div class="display:none;">
<div id="div1">...</div>
<div id="div2">...</div>
......
</div>
So that those tooltip contents are not visible unless required.
Tooltip can be populated with the content fetched from external files such as text document, XML document, or other web pages.
For example:
<input onfocus="tooltip.ajax(this, 'help/tip1.txt')" type="text" name="email" />
Quick start
It is as easy as the following 1-2-3 to get the tooltip to work.
How to Set Tooltip Content
- tooltip.pop(targetElement, text[, options])
- tooltip.pop(targetElement, '#contentElementId' [, options])
- tooltip.ajax(targetElement, url[, ajaxSettings, options])
Tooltip Options
You can configure the tooltip global options by modifying the var tooltipOptions in the tooltip.js.
Special Options for Individual Tooltip
Each individual tooltip instance can have its own special options which are different from the global options. To achieve this you just need to pass the option object into the tooltip trigger method (tooltip.pop or tooltip.ajax). Example 1 Example 2 Example 3
License and Purchase
Menucool Tooltip can get more use than you can imagine
- Tooltip Menu: The tooltip can be used as navigation menu
- Login (dummy)
- demo 4: The tooltip can be controlled programmatically
- Thumbnail Preview: The tooltip can be easily integrated into other Web UI widgets
Customize Tooltip Styles
You can easily customize the tooltip style through the tooltip.css file.
The tooltip markup is generated by the tooltip.js script. We'll show you the tooltip HTML structure which will help you use appropriate CSS selectors to style the tooltip:
<div id="mcTooltipWrapper">
<div id="mcTooltip">
<div class="mcTooltipInner">
(Tooltip content)
</div>
</div>
<div id="mcttCo"></div>
<div id="mcttCloseButton"></div>
</div>
<div id="mcOverlay"></div>