我为我的链接编写了一个快速的工具提示函数:
问题是我无法将其添加回去。 我尝试过:
但是它失败了。有什么建议吗?
$(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});
})
});
我希望删除原始标题,因为同时存在两个标题是愚蠢的。我知道应该像这样操作:
$('a').hover(function() {
$(this).attr('title', '');
});
问题是我无法将其添加回去。 我尝试过:
$(this).attr('title', title) //from my title variable
但是它失败了。有什么建议吗?