Home arrow JavaScript arrow Page 3 - Tracking Mouse Movements with the jQuery Tooltip Plug-in
JAVASCRIPT

Tracking Mouse Movements with the jQuery Tooltip Plug-in


In this second installment of a seven-part series focused on the jQuery Tooltip plug-in, I demonstrate how to customize its behavior and appearance. First I discuss the use of the “track” parameter, which makes tooltips follow mouse movements, and then I show how to work with the “showURL” argument to prevent “href” attributes from being displayed within the tooltip.

Author Info:
By: Alejandro Gervasio
Rating: 5 stars5 stars5 stars5 stars5 stars / 2
October 26, 2009
TABLE OF CONTENTS:
  1. · Tracking Mouse Movements with the jQuery Tooltip Plug-in
  2. · Review: adding default tooltips to web page links
  3. · Tracking mouse movements
  4. · Hiding URL values from display with the showURL input argument

print this article
SEARCH DEVARTICLES

TOOLS YOU CAN USE

advertisement
Tracking Mouse Movements with the jQuery Tooltip Plug-in - Tracking mouse movements
(Page 3 of 4 )

Providing tooltips with the capacity to follow mouse movements is only a matter of calling the "tooltip()" JavaScript method with an additional input argument named "track." This can be assigned a Boolean value, where TRUE means that the tooltip will track the mouse's pointer, and logically FALSE won't. It's that simple.

However, the best way to understand how this parameter affects the behavior of a tooltip is by means of a concrete example. Below I included a brand new code sample that shows how the "track" argument works. Have a look at it, please:


<!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Strict//EN" "http://www.w3.org/TR/xhtml1/DTD/xhtml1-strict.dtd">

<html xmlns="http://www.w3.org/1999/xhtml">

<head>

<meta http-equiv="Content-Type" content="text/html; charset=iso-8859-1" />

<title>Tooltip example with mouse tracking enabled</title>

<link rel="stylesheet" type="text/css" href="jquery.tooltip.css" />

<script type="text/javascript" src="jquery.js"></script>

<script type="text/javascript" src="jquery.dimensions.js"></script>

<script type="text/javascript" src="jquery.tooltip.js"></script>

<script type="text/javascript">

// assign tooltip to links after web page has been loaded

// delay tooltip display 800 ms and track mouse position

$(document).ready(function(){

$("a").tooltip({

delay: 400,

track: true

});

});

</script>

</head>

<body>

<ul>

<li><a href="http://jquery.com" title="Sample Link 1">Sample Link 1</a></li>

<li><a href="http://jquery.com" title="Sample Link 2">Sample Link 2</a></li>

<li><a href="http://jquery.com" title="Sample Link 3">Sample Link 3</a></li>

<li><a href="http://jquery.com" title="Sample Link 4">Sample Link 4</a></li>

<li><a href="http://jquery.com" title="Sample Link 5">Sample Link 5</a></li>

<li><a href="http://jquery.com" title="Sample Link 6">Sample Link 6</a></li>

</ul>

</body>

</html>

Here you have it. By assigning a TRUE value to the "track" argument, all of the tooltips that have been attached to the previous web page links will follow mouse movements, thus creating a classic "tail" effect. But, naturally you don't have to take my word for it. Try the above example on your own browser and see how the tooltips will stick to the mouse position. In addition, you may have noticed that I used this tracking feature along with the already familiar "delay" parameter, meaning that tooltips will be displayed on screen with a delay of 400 milliseconds.

Now that you hopefully understand how to utilize the "track" argument with the Tooltip jQuery plug-in, it's time to see a slight variation of the previous example. This time I'm going to show you how to create tooltips that follow mouse movement, but without displaying the value assigned to the web page links.

This topic will be discussed in detail in the following segment. Therefore, to learn more about it, please click on the link below and read the next few lines.


blog comments powered by Disqus
JAVASCRIPT ARTICLES

- More Top jQuery Tutorials for Beginners
- More Top jQuery Plugins for Menus
- Top jQuery Tutorials for Beginners
- New UI Framework and SDK for JavaScript Rele...
- JavaScript OpenPGP Tool, Node.js 0.6.3 Avail...
- Yahoo Releases Cocktails Language and Develo...
- Customizing jQuery Slideshows: Dynamic Contr...
- Customizing jQuery Slideshows: the animate()...
- Customizing jQuery Slideshows: slideUp() and...
- Customizing jQuery Slideshows: hide() and sh...
- Web Workers: Performing Calculations in Para...
- More Top JavaScript Frameworks and Libraries
- More Dynamic jQuery Styling Techniques
- The Top JavaScript Libraries
- The Top JavaScript Frameworks

Dev Articles Forums 
 RSS  Articles
 RSS  Forums
 RSS  All Feeds
Weekly Newsletter
 
Developer Updates  
Free Website Content 
Contact Us 
Site Map 
Privacy Policy 
Support 



© 2003-2012 by Developer Shed. All rights reserved. DS Cluster 10 - Follow our Sitemap
Popular Web Development Topics
All Web Development Tutorials