1. INCLUDE CSS AND JS FILES
<link href="css/tooltip.css" rel="stylesheet" type="text/css">
<script src="js/jquery.min.js"></script>
<script src="js/jquery.tooltip.js"></script>
2. HTML
<button class="btn btn-primary" id="button1" title="Button 1 tooltip text">default position, convert title to tooltip</button>
3. JAVASCRIPT
$('#button1').tooltip();
4. OPTIONS
text {String} tooltip text (can be html)
position {String} tooltip position in relation to the target (selector) it can be 1 of the following:
- 'auto' or 'default' (or not set) to auto calculate the position
- tl, t, tr, bl, b, br, lt, l, lb, rt, r, rb - to force a particular position
if tooltip goes out of the screen - the position will be auto-updated to show it in a viewport (to enforce the position use "forcePosition" instead)
forcePosition {Boolean} true to enforce the position even if tooltip goes out of the screen
animate {Bool|Int} animate fadeIn/Out, defaults to false (IE always false), it can be also an anim speed in milisec
trigger {String} show tooltip event listener [hover|click|manual], defaults to 'hover'
showDelay {int} delay showing the tooltip for x miliseconds, defaults to 100
dontHideOnTooltipHover {Bool} don't hide the tooltip when mouse is over it
cls {String} additional css class for the tooltip
selector {String} if not empty - tooltip will be attached to the target but event will be filtered by this selector
5. EXAMPLES
$(function(){
var html1 = '<h2>Tooltip title</h2><p>Tooltip description</p>',
html2 = '<h2>Tooltip title</h2><p>A very loong tooltip description text<br> with multiple lines<br>and some links: <a href="#">Link</a></p>';
$('#button1').tooltip(); // convert "title" attribute to a tooltip
$('#button2').tooltip('Button 2 tooltip text'); // show custom text
$('#button3').tooltip(html1); // show html
$('#button4').tooltip({ position: 'tr', animate: 0 }); // position top-right, no animation
$('#button5').tooltip({ position: 'bl', cls: 'custom-tooltip' }); // position bottom-left, custom css class
$('#button6').tooltip({ position: 'r', animate: 1000, text: html1, cls: 'big-tooltip' }); // position right, html content, long animation
$('#button7').tooltip({ position: 't', trigger: 'click' }); // position top, show on click
$('#button8').tooltip({ position: 't', dontHideOnTooltipHover: true });
$('#button9').tooltip({ position: 'r', dontHideOnTooltipHover: true, text: html2, cls: 'big-tooltip', showDelay: 1000 });// position left, show with 1000ms delay
$('#button10').tooltip({ position: 't', dontHideOnTooltipHover: true, text: html2, cls: 'big-tooltip' });
$('#button11').tooltip({ position: 'lt', dontHideOnTooltipHover: true, text: html2, cls: 'big-tooltip' });
$('#button12').tooltip({ position: 'lb', dontHideOnTooltipHover: true, text: html2, cls: 'big-tooltip', forcePosition: true });
$('body').tooltip({ selector: '.lazy' });
$('body').on('click', '.btn.lazy', function() { $(this).clone().insertAfter(this); }); // clone button on click
});