For example, create a folder called SpryAssets in the root folder of your web site, and move the SpryTooltip.js file to it. The SpryTooltip.js file contains all of the information necessary for making the Tooltip widget interactive.
<script src="SpryAssets/SpryTooltip.js" type="text/javascript"></script>
Make sure that the file path to the SpryTooltip.js file is correct. This path varies depending on where you’ve placed the file in your web site.
<link href="SpryAssets/SpryTooltip.css" rel="stylesheet" type="text/css" />
Make sure that the file path to the SpryTooltip.css file is correct. This path varies depending on where you’ve placed the file in your web site.
<p>This will be the <span id="trigger">tooltip trigger</span>.</p>
<p>This will be the <span id="trigger">tooltip trigger</span>.</p> <div id="container">This is the tooltip content</div>
<p>This will be the <span id="trigger">tooltip trigger</span>.</p>
<div id="container">This is the tooltip content</div>
<script type="text/javascript">
var tooltip_one = new Spry.Widget.Tooltip("container","#trigger");
</script>
The required arguments for the tooltip constructor are the ID of the tooltip container (“container” in our example), and the CSS selector for the tooltip trigger (“#trigger”). In the example, we’ve placed the # sign in front of the ID to transform the ID into a CSS selector. The selector can specify an element ID, a class name, an HTML tag name, or a more complex selector that’s a combination of these.
You might want to turn your triggers into
links so that people recognize them as active areas. If you want
to do this, you can change the <span id="trigger"> tag
to <a href="#" id="trigger">. (Don’t forget
to change the closing tag as well.) Or if you don’t want to create
a null link, you can define a CSS class (that sets a different background color
for example), and apply it to the tooltip to differentiate it from
surrounding text.