我创建了一个函数,根据用户悬停的链接ID显示引导工具提示。
警告this.id在标题功能中是空白的 - 我是否需要通过此,如果是,如何? (这)不起作用,我尝试了一些其他方法无济于事。谢谢!
$(document).ready(function(){
$('.tooltiplink').tooltip({
html: true,
title: function() {
return $('#' + this.id).html();
}
});
});
答案 0 :(得分:1)
使用$(this)
。无需使用$('#' + this.id)
。
$(this)
已经是您正在寻找的元素。
$(document).ready(function(){
$('.tooltiplink').tooltip({
html: true,
title: function() {
return $(this).html();
}
});
});