I kinda cringe at the coding practices used there. So I've rewritten it from the ground up. Here's a demo page:
Code:
<!DOCTYPE html>
<html>
<head>
<title>jQuery Fixed Tooltip</title>
<meta http-equiv="Content-Type" content="text/html; charset=utf-8">
<style type="text/css">
#tooltip {
position: absolute;
border: 1px solid #333;
background: #f7f5d1;
padding: 2px 5px;
color: #333;
display: none;
}
</style>
<script type="text/javascript" src="http://ajax.googleapis.com/ajax/libs/jquery/1.4/jquery.min.js"></script>
<script type="text/javascript">
jQuery(function($){
$('body').append('<div id="tooltip"></div>');
var tt = $('#tooltip');
$('a.tooltip').each(function(){
$(this).data('title', this.title).attr('title', '');
}).hover(function(){
var t = $(this), o = t.offset();
tt.html(t.data('title')).css({top: o.top + t.height(), left: o.left}).fadeIn('fast');
},
function(){
tt.css({display: 'none'});
});
});
</script>
</head>
<body>
<h1>jQuery Fixed Tooltip</h1>
<p>Take a trip to <a href="http://www.google.com" class="tooltip" title="Google, the web's most popular Search Engine">Google</a></p>
<p>or <a href="http://www.dynamicdrive.com" class="tooltip" title="DHTML scripts for the real world!">Dynamic Drive</a></p>
</body>
</html>
Bookmarks