我为我的链接编写了这个快速工具提示功能:
$(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
但它失败了。建议?