views:

51

answers:

2

In my javascript file there is,

var htm = '<div style="overflow:hidden;height:24px;width:150px;" onmouseover="tooltip(this)">' ;

function tooltip(sp)
{
    sp.title = sp.innerHTML;
}

So on mouse over a text the tooltip is displayed.But the tool tip does not stay longer. meaning the position is not fixed. Can the code be modified such that mouse over should be done on the text and the tool tip also........

+1  A: 

If all you want is a "built-in" tooltip, there's no need at all to do it dynamically. Just code the HTML element with a "title" attribute containing the text you want. The browser will show the tooltip on mouseover. If you want something fancier, you should probably look at a jQuery add-on (or some other framework).

Pointy
+1 - jQuery qTip is good: http://craigsworks.com/projects/qtip/
Jonathan Sampson
if you are not interested to use jQuery/prototypejs only for the tooltip plugin, you can try the following link,http://amar-desh.net/myworks/javascript/ToolTip_using_javascript.aspxThanks.
Hoque
A: 

Here is a standards based tooltip that will serve you well.

<div title="This is your tooltip">Some Text</div>

If you then wish to add on top of this, you can use the title attribute to get the text you want to display as a tooltip, which is how various tooltip plugins work.

Sohnee