2017-04-11 120 views
1

我是jquery的新手,這個問題與jquery相比更加相關。任何幫助表示讚賞。jquery tooltipster插件不能正常工作

我使用Tooltipster Plugin創建工具提示,每次我將鼠標懸停在數據表中的<td>元素上時。爲此,我已將數據表中的每一行循環,然後使用子節點選擇<td>元素,並應用.tooltipster()函數。但是,工具提示僅適用於第1行<td>元素。任何想法如何讓它適用於所有行?

$('#mytable tbody tr').each(function(){ 
    //childNode[7] is the <td> element on which i want the tooltip 
    $(this.childNodes[7]).tooltipster({  
      animation: 'fade', 
      delay: 200, 
      theme: 'tooltipster-punk', 
      trigger: 'hover', 
      interactive: 'true', 
      functionBefore : function drawChart() { 
    // This isnt needed to understand the problem so i have not pasted the code 
} 

}); 
}); 

表數據

<td class="tooltip" data-tooltip-content="#chart_div" style="padding-left:40px" id="storage" > 
     <img src="@Url.Content("~/Content/images/database.png")" /> 
</td> 
+0

如果你只需要一個小文本作爲工具提示,那麼使用「title」而不是tooltip,這將會更容易和簡單。 –

+0

你爲什麼又問這個問題?我在另一個回答。 –

回答

0

這是給你的建議。

如果您只需顯示文本作爲您的元素的工具提示,那麼只需使用title。

標題的使用很簡單。

例如,

HTML

<div title="your tooltip here">The content of the document......</div> 

截圖

sample screenshot

這將是一個簡單的步驟,以解決您的問題。