Today, I upgraded all of my jQuery plugs-in with jQuery 1.9.1. And I started to use jQueryUI tooltip with jquery.ui.1.10.2. Everything was good. But when I used HTML tags in the content (in the title
attribute of the element I was applying the tooltip to), I noticed that HTML is not supported.
This is screenshot of my tooltip:
How can I make HTML content work with jQueryUI tooltip in 1.10.2?
Instead of this:
use this for better performance
thanks for post and solution above.
I have updated the code little bit. Hope this might help you.
http://jsfiddle.net/pragneshkaria/Qv6L2/49/
You can also achieve this completely without jQueryUI by using CSS styles. See the snippet below:
The first span is for the displayed text, the second span for the hidden text, which is shown when you hover over it.
I solved it with a custom data tag, because a title attribute is required anyway.
Like this it is html conform and the tooltips are only shown for wanted tags.
another solution will be to grab the text inside the
title
tag & then use.html()
method of jQuery to construct the content of the tooltip.Example: http://jsfiddle.net/hamzeen/0qwxfgjo/
Edit: Since this turned out to be a popular answer, I'm adding the disclaimer that @crush mentioned in a comment below. If you use this work around, be aware that you're opening yourself up for an XSS vulnerability. Only use this solution if you know what you're doing and can be certain of the HTML content in the attribute.
The easiest way to do this is to supply a function to the
content
option that overrides the default behavior:Example: http://jsfiddle.net/Aa5nK/12/
Another option would be to override the tooltip widget with your own that changes the
content
option:Now, every time you call
.tooltip
, HTML content will be returned.Example: http://jsfiddle.net/Aa5nK/14/