I have used several different tooltip plugins over the years, but I think it's time to write my own. I'm just not looking for a plugin that has all the options, because I know how I want each tooltip to pop up to look and behave. Most plugins have a range of animations and positions available, and I think this is excessive for the lung I want to create with your help, of course :)
Basically, using the title attribute of the guidance, I want the tooltip to display directly above and center with the hover element.
I know how to populate the div to be shown, but what I'm trying to work out is how to say that the div positions itself directly above the element.
Ideally, this is done with minimal code. My logic says something like this (pseudo code):
<html> <head> <style type="text/css"> #myToolTip { display: none; } </style>
<script type="text/javascript"> $(document).ready(function() { $('.hoverAble').hover(function(){ var tip = $(this).attr('title'); $('#myToolTip').html(tip).fadeIn(); }, function() { $('#myToolTip').fadeOut(); } }); </script> </head> <body> <div id="myToolTip"></div> <div class="hoverAble" title="I am good at code"></div> </body> </html>
Of course, the above code will simply pop up a tooltip and will not be positioned relative to the hovering element. Where my understanding does not fit. You can help?
Edit: Just for clarification, I don't want the tooltip to be moved with the mouse.
jquery css
willdanceforfun
source share