I'm attempting to use HTML5 data attributes to store and display content for a tooltip.
I'm using JQuery UI for the tooltip.
I've read the documentation, but haven't figured out how to program the right selector and display the custom data.
Any ideas of what I'm missing?
HTML:
<span class="info-icon"
data-title="custom title"
data-desc="custom description">
</span>
JS:
$( '.info-icon' ).tooltip({
content: function() {
return 'Title: ' + $( this ).data('title') +
' Description: ' + $( this ).data('desc');
}
});
ready(function() {instead ofready({. Second, you should add your jQuery UI theme's CSS file as an external resource to your fiddle (and maybe in your page also). The rest of the code looks fine.