Skip to content

Instantly share code, notes, and snippets.

@megaxorg
Created Mar 25, 2013
Embed
What would you like to do?
<a href="#" class="tooltip" title="Content of the tooltip"> Style with #tooltip
function tooltip(obj) {
if (!obj.length) return;
$("body").append('<div id="tooltip" />');
var tooltip = $("#tooltip");
var title;
obj.hover(function() {
title = $(this).attr("title") ? $(this).attr("title") : "No Title";
$(this).attr("title","");
tooltip.html(title);
tooltip.stop(true,true).delay(50).fadeIn("slow").dequeue();
},function() {
$(this).attr("title",title);
tooltip.stop(true,true).fadeOut("slow");
}).mousemove(function(e) {
tooltip.animate({
top:e.pageY + 10,
left:e.pageX + 10
},200);
});
}
jQuery(document).ready(function(){
tooltip($(".tooltip"));
});
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment