0

ツールチップ内の data-content-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
    }
});
});
});   

理解を深めるために、ここにフィドルあります。

4

1 に答える 1

0

text関数を受け入れると思うので、試してください:

// 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: function () {
                    return $(this).next('[data-contentid]').data('contentid'); 
                }
            }
        });
    });
});

フィドル

またはむしろこの方法:(私はあなたのhtml構造を理解していません)

フィドル

于 2013-09-25T01:44:09.913 に答える