I wrote this quick tooltip function for my links:
$(function() {
$('a').hover(function(e) {
var title = $(this).attr('title');
$('<div id="tooltip">' + title + '</div>').css({"top" : e.pageY + 12, "left" : e.pageX + 12}).appendTo('body');
}, function() {
$('#tooltip').remove();
});
$('a').mousemove(function(e){
$('#tooltip').css({"top" : e.pageY + 12, "left" : e.pageX + 12});
})
});
I want to remove the original title because having both is stupid. I know I should go something like this:
$('a').hover(function() {
$(this).attr('title', '');
});
The problem is that I can't add it back. I tried:
$(this).attr('title', title) //from my title variable
but it failed. Suggestions?