smo smo - 1 year ago 133
jQuery Question

jQuery Tools Tooltip - Change Title

Got a problem with the jquery plugin Tools tooltip (
I need to change the title of the element..

$("#example").attr('title', obj.text);

function reloadTooltip(){
$("[title]").tooltip({ position: "bottom right", opacity: 1 });

Html Part:

<span title="text" id="example"></span>

With my solution i got finally 2 titles, one above the other. The unstyled (ignored js), is the new one. The Tools tooltip title has not changed yet.

thank you

Answer Source

I'm about to do the same thing. I looked through the Tooltip plugin code, and discovered as quick and easy way to update the tooltip. The plugin removes the title attribute and puts that content into an element property called tooltipText. In jQuery 1.6+, it can be manipulated like so:

// get the current tooltip content

// set the tooltip content
$('#someElement').prop('tooltipText', 'w00t');

The plugin sets the tooltipText property (note the capitalization) at line 55 in version 1.3. Changes done this way are instantaneous as far as I can tell.

If doing direct element manipulation, the tooltip content is at:

var e = document.getElementById('#someElement');
e.tooltipText = 'w00t';