I'm looking for a lightweight jquery plugin for displaying tooltips when the user hovers over an element. I would like the plugin to get the content from the title attribute and also it's important that I can make new lines.
Any help is appreciated!
I usually use tipsy.
You can add any html element in tipsy, so
<br/>
works.You just need to pass the
html
option as such :If you don't want to use the
title
attribute to display html (it won't validate in this case), you can use thefallback
option.More options and examples on the tipsy webpage.
Most browsers (not Firefox or Opera - newlines will disappear) support newlines in the
title
attribute.If your plugin doesn't render them as
<br />
, do this on the text first...... and then pass
tooltip
to your tooltip library (e.g. qTip).http://elliotlings.com/jquery/tooltip is a good tooltip to manage tooltips which need to hold more content
Simple custom jQuery extension:
This creates a
<div class="myToolTip">
(use CSS to style it) and positions it beneath the element in question on mouseenter. On mouseleave the tooltip is removed again. Line breaks in the element'stitle
will become<br>
in the<div>
's contents, everything else will appear verbatim.Call the extension via
$(".someElements").myToolTip();
.In jQuery 1.9 (jquery + jquery-ui) and standard toolTip function use this:
And then in the title you can use HTML's
or .
Example:
You can use this example:
After add html tag "
" inside title: