繁体   English   中英

Bootstrap工具提示-如何访问“此”

[英]Bootstrap Tooltip - How can I access “this”

我创建了一个函数,用于根据用户悬停的链接的ID显示引导工具提示。

提醒this.id在标题函数内为空白-我需要通过吗? (this)不起作用,我尝试了其他一些方法也无济于事。 谢谢!

$(document).ready(function(){
  $('.tooltiplink').tooltip({ 
    html: true,
    title: function() {
      return $('#' + this.id).html();
    }
  });
});

使用$(this) 无需使用$('#' + this.id) $(this)已经是您要查找的元素。

$(document).ready(function(){
  $('.tooltiplink').tooltip({ 
    html: true,
    title: function() {
      return $(this).html();
    }
  });
});

暂无
暂无

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM