Simple and lightweight tooltip module. Examples
minified and gzipped about 1.8 kB
npm i ttips
HTML:
Put a containter with a .ttip class behind the element that should trigger the tooltip (previousElementSibling selects the tooltip target).
<div>Tooltip target</div>
<div class="ttip">Tooltip content</div>
<!-- Position the tooltip via data-attribute, can be 'left', 'top' or 'right' and defaults to bottom -->
<div>Tooltip target</div>
<div class="ttip" data-ttip-position="left">Tooltip content</div>
JS:
var ttips = require('ttips'); // or use the standalone version from the dist folder
// initialize the tooltips
ttips.initialize();
// update the tooltips, e.g after a dom change
ttips.update();
// hide tooltip, does nothing if no tooltip is visible
ttips.hide();
// destroy ...
ttips.destroy();
npm i && npm run build
MIT