Posts: 3,985
Name: Abel Mohler
Location: Asheville, North Carolina USA
|
Just hide the tooltip on mouseout, and show it on mouseover. What are you not understanding there? The way I do it I use as much raw JavaScript as possible, because it is faster (using all jQuery functions will definitely slow things down).
Also of note, you should be using the clientX and clientY properties to track the mouse position instead of pageX and pageY, because it is (I think) more compatible and accurate across browsers.
If you want to study my tooltip, here it is: jQuery tooltip
Also, take advantage of jQuery's plugin mechanism! It is awesome, though it isn't anything special: all you do is build prototypes of the jQuery object. If you've never built a prototype before, now is a good time to learn. Think of prototype functions as being able to inherit all of the properties of their parent functions, because that is exactly what they do. When you build a prototype of jQuery, you may refer to the DOM object it creates with the "this" keyword. The "this" in jQuery is always an array object, even if it is only one item.
When you make a plugin, always return "this", or the element chain via an $().each, so that your function can be chained to more functions.
jQuery's inheritance scheme is very much like class-based inheritance, but in a uniquely JavaScript manner, which is why I like it so much.
Last edited by wayfarer07; 03-04-2009 at 07:15 PM..
|