簡體   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