2

いくつかの入力とテキストエリアを含む html ページがあります。さまざまなテキストの qTip が必要です。

これが私の試みですまず、すべての要素にqTipを追加します。

$('input, textarea').each(function() {
        $(this).qtip(
                { 
                content : 'generated', //this is for debug
                position : {

                    my : 'center left',
                    at : 'center right',
                    adjust : {
                        x : 90
                    }
                }
            });
});

そして、このようにqTipテキストを変更しようとしています

$("#firstName").qtip('option', 'content.text', 'adwd');

しかし、それは機能していません。

私はこれを試しました

$("#lastName").qtip({
    content : 'text text'
});

これは正常に機能していますが、位置をオーバーライドします

4

1 に答える 1

6

このコードは私のために働いています:

$("#firstName").qtip('option', 'content.text', 'new tooltip content')

イベントで変更する必要がある場合 (例: over または類似)、次のコードを使用してみてください。

// make sure you target a specific tip
var qapi = $('#firstName').data('qtip'),
newtip = 'new tooltip content'
qapi.options.content.text = newtip; // update content stored in options
qapi.elements.content.text(newtip); // update visible tooltip content
qapi.redraw(); // redraw to adjust tooltip borders

コードは特定のオプションのみを更新し、他のオプションはそのままにします。

デモ: http://jsfiddle.net/IrvinDominin/L7fs5/

于 2013-08-29T21:07:02.887 に答える