Tooltip Module

Usage

Trigger the tooltip via JavaScript:

query('#example').tooltip(options)

Markup

For performance reasons, the Tooltip and Popover data-apis are opt in. If you would like to use them just specify a selector option.

<a href="#" rel="tooltip" title="first tooltip">hover over me</a>

Options

Options can be passed via data attributes or JavaScript. For data attributes, append the option name to data-, as in data-animation="".

Nametypedefaultdescription
animationbooleantrueapply a css fade transition to the tooltip
htmlbooleantrueInsert 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.
placementstring|function'top'how to position the tooltip - top | bottom | left | right
selectorstringfalseIf a selector is provided, tooltip objects will be delegated to the specified targets.
titlestring | function''default title value if `title` tag isn't present
triggerstring'hover'how tooltip is triggered - click | hover | focus | manual
delaynumber | object0

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: delay: { show: 500, hide: 100 }

Heads up! Options for individual tooltips can alternatively be specified through the use of data attributes.

Methods

MethodsDescription
destroyHides and destroys an element's tooltip.
hideHides an element's tooltip.
showReveals an element's tooltip.
toggleToggles an element's tooltip.

Examples

Inspired by the excellent jQuery.tipsy plugin written by Jason Frame; Tooltips are an updated version, which don't rely on images, use CSS3 for animations, and data-attributes for local title storage.

Hover over the links below to see tooltips:

Tight pants next level keffiyeh you probably haven't heard of them. Photo booth beard raw denim letterpress vegan messenger bag stumptown. Farm-to-table seitan, mcsweeney's fixie sustainable quinoa 8-bit american apparel have a terry richardson vinyl chambray. Beard stumptown, cardigans banh mi lomo thundercats. Tofu biodiesel williamsburg marfa, four loko mcsweeney's cleanse vegan chambray. A really ironic artisan whatever keytar, scenester farm-to-table banksy Austin twitter handle freegan cred raw denim single-origin coffee viral.

Four directions