02.06.2015 Views

Bootstrap Tutorial

Create successful ePaper yourself

Turn your PDF publications into a flip-book with our unique Google optimized e-Paper software.

CHAPTER<br />

39<br />

<strong>Bootstrap</strong> Tooltip Plugin<br />

Tooltips are useful when you need to describe a link. The plugin was inspired by jQuery.tipsy plugin written<br />

by Jason Frame. Tooltips have since been updated to work without images, animate with a CSS animation, and<br />

data-attributes for local title storage.<br />

If you want to include this plugin functionality individually, then you will need tooltip.js. Else, as mentioned in the<br />

chapter <strong>Bootstrap</strong> Plugins Overview, you can include bootstrap.js or the minified bootstrap.min.js.<br />

Usage<br />

The tooltip plugin generates content and markup on demand, and by default places tooltips after their trigger<br />

element. You can add tooltips in the following two ways:<br />

<br />

Via data attributes: To add a tooltip, add data-toggle="tooltip" to an anchor tag. The title of the anchor will<br />

be the text of a tooltip. By default, tooltip is set to top by the plugin.<br />

Hover over me<br />

<br />

Via JavaScript: Trigger the tooltip via JavaScript:<br />

$('#identifier').tooltip(options)<br />

Tooltip plugin is NOT only-css plugins like dropdown or other plugins discussed in previous chapters. To use this<br />

plugin you MUST activate it using jquery (read javascript). To enable all the tooltips on your page just use this<br />

script:<br />

$(function () { $("[data-toggle='tooltip']").tooltip(); });<br />

EXAMPLE<br />

The following example demonstrates the use of tooltip plugin via data attributes.<br />

Tooltip examples for anchors<br />

This is a <br />

Default Tooltip<br />

.<br />

This is a <br />

Tooltip on Left<br />

.<br />

TUTORIALS POINT<br />

Simply Easy Learning

Hooray! Your file is uploaded and ready to be published.

Saved successfully!

Ooh no, something went wrong!