q99*_*q99 2 html javascript jquery qtip2
我有一个带有一些输入和textareas的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
}
}
});
});
Run Code Online (Sandbox Code Playgroud)
然后我试图改变像这样的qTip文本
$("#firstName").qtip('option', 'content.text', 'adwd');
但它不起作用.
我试过这个
$("#lastName").qtip({
content : 'text text'
});
Run Code Online (Sandbox Code Playgroud)
这工作正常但它超越了位置
这段代码对我有用:
$("#firstName").qtip('option', 'content.text', 'new tooltip content')
Run Code Online (Sandbox Code Playgroud)
如果您必须在事件上更改它(例如,超过或类似),请尝试使用以下代码:
// 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
Run Code Online (Sandbox Code Playgroud)
代码仅更新特定选项,并保留其他选项.
演示:http://jsfiddle.net/IrvinDominin/L7fs5/