我有一个包含一些输入和文本区域的 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'
});
工作正常但它覆盖了位置
最佳答案
这段代码对我有用:
$("#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
代码仅更新特定选项,其他选项保持原样。
关于javascript - qTip 在每个之后更改特定工具提示的文本,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/18520168/