I like to be able to load a tooltip from a file "a la ajax" style.... but first i like to see if i am able to "transfert" html text to the title attribute
i use jquery and tooltip (from http://jquery.bassistance.de/tooltip/demo/)
here is the code
<div class="odeurbox">
<img src="odeurs/aiguilledepin.jpg"
width="67" height="67" />
Aiguille de pin </div>
<div class="tohide">
<h3>Agrumes :</h3>
<p>Les agrumes sont les fruits des végétaux des g....</p>
<em>Source : Le Petit Robert 2009</em></div>
that way, it will be super easy to edit (real text) not hidden into title attribute
- so,i need to add visibility : hidden to the css class tohide
- get the whole content of div with class .tohite and pu it in the previous div title
my jquery code i have done yet dont work... what should be the correct way to do that
in short, for each div with class .odeur get the content of the next (child?) tohide and put it in the attribute title=''
something like that dont work yet :
$('div.odeurbox').each(function(){$(this).attr("title", $('.tohide').html());});
Well actually you can put raw HTML into the title field. As long as you replace all quotes in the HTML with
"
or use single quotes (like I did below).I've used this tooltip in the past to do just that. The title contains the tooltip data that is displayed. And that script has been modified here to pull data from an assigned ID when it finds a flag in the title.
Here's an example of how to use this tooltip:
So, you basically want to store raw HTML into the title field? That simply does not work. It would create HTML Errors of unholy proportions.
Instead, why don't you just store the Text into the title field (but only if you must... a Javascript Object with the contents would be more practicable [AND you can store raw HTML into them ;)])
In case you store the tooltip text into the title field, you won't need any Javascript to create a tooltip... The Browser does that for you.
If you do want a custom tooltip, I would suggest creating an empty div that serves as tooltip, and then extract the text it displays from a Javascript Object.
For Instance:
HTML for the images
HTML for the tooltip. This can be anywhere as long as it is not a child of an Element it has to tip
JavaScript
Then, with jQuery
This should work even without any Plugins.