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')

如果您必须在事件(例如结束或类似)上更改它,请尝试使用此代码:

// 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 回答