Tooltip data from a static text / an element (id) / a function return / ajax get from url
The tooltip plugin generates content and markup on demand, and by default places tooltips after their trigger element.
Trigger the tooltip via JavaScript:
$('#example').tooltip(options)
The generated markup of a tooltip is rather simple, though it does require a position (by default, set to top by the plugin).
<div class="tooltip">
<div class="tooltip-inner">Tooltip!</div>
<div class="tooltip-arrow"></div>
</div>
Options can be passed via data attributes or JavaScript. For data attributes, append the option name to data-, as in data-animation="".
Name | type | default | description |
---|---|---|---|
html | boolean | false | Insert HTML into the tooltip. If false, jQuery's text method will be used to insert content into the DOM. Use text if you're worried about XSS attacks. |
placement | string | function | 'top' | how to position the tooltip - top | bottom | left | right | auto. When "auto" is specified, it will dynamically reorient the tooltip. For example, if placement is "auto left", the tooltip will display to the left when possible, otherwise it will display right. |
title | string | function | '' | default title value if title attribute isn't present |
trigger | string | 'hover focus' | how tooltip is triggered - click | hover | focus | manual. You may pass multiple triggers; separate them with a space. |
delay | number | object | 0 | delay showing and hiding the tooltip (ms) - does not apply to manual trigger type If a number is supplied, delay is applied to both hide/show Object structure is: |
dataType | string | 'text' | how to data type the tooltip - text | id | function | url text : Static text title="Static text" id : an element id attributetitle="#elementId" data-tooltip-type="id" function : a javascript function into the page title="funcName(x,y)" data-tooltip-type="function" url : get data with ajax from url title="data.html" data-tooltip-type="url" |