Simple JavaScript tooltip for HTML elements. No extra CSS required.
Chrome 7, Firefox 4.0, IE9 Opera 11.60, Safari 5.1.4.
The browser support can be extended to IE8 and friends if you have a polyfill for Function.prototype.bind
<!-- Include the method in your library. -->
<script src="/js/tooltip.js"></script>
You can send the content as a string:
new tooltip({
elem: document.getElementById('myLinkId'),
content: '<div>My HTML content here.</div>'
});
You can send the content as a DOM node:
new tooltip({
elem: document.getElementById('myLinkId'),
content: document.getElementById('myLinkTooltipContent')
});
<div class="tooltip">
<div class="tooltip-content">
<!-- Your content -->
</div>
</div>
Add an issue or fork the project and submit a pull request.
If this script helped you save a lot of developing time, I really appreciate any donations
.