我需要從工具提示內的數據內容ID獲取內容。出於某種原因,它不會抓住內容並將其拉入內部。工具提示中的數據-id內容
下面是代碼:
// Create the tooltips only when document ready
$(document).ready(function()
{
/// Grab all elements with the class "hasTooltip"
$('.hasTooltip').each(function() { // Notice the .each() loop, discussed below
$(this).qtip({
content: {
text: $('#tooltip-content-' + $(this).find('[data-contentid]').data('contentid')) // Grab content using data-content-id attribite value
}
});
});
});
爲了更好地理解這裏是一個小提琴:http://jsfiddle.net/L6yq3/465/在這裏你可以看到,我不能得到提示裏面的「CONTENTEXAMPLE」。
這將是jQuery,而不是簡單的[javascript]如標籤所示...您可以在大多數瀏覽器上設置somenode.title =「您的工具提示文本」(或標題=「您的工具提示文本」在html標籤中),以便於在大多數瀏覽器上獲得「工具提示」檢索沒有jquery – technosaurus