javascript - qTip 在每个之后更改特定工具提示的文本

标签 javascript jquery html qtip2

我有一个包含一些输入和文本区域的 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

代码仅更新特定选项,其他选项保持原样。

演示:http://jsfiddle.net/IrvinDominin/L7fs5/

关于javascript - qTip 在每个之后更改特定工具提示的文本,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/18520168/

相关文章:

javascript - 谷歌云函数: Why won't this work?

javascript - 如何在 overflow auto 中提出 div 元素?

javascript - 如何使用d3获取当前选定对象的颜色

javascript - 如何显示/隐藏网格中的所有列?

php - 使用 jquery ajax 和 php 将动画表单提交到 mysql 数据库

javascript - 将表单上的 javascript 验证更改为 onblur 或 onchange 而不是提交

javascript - 迭代匹配元素来控制自定义光滑轮播

html - 将图像从特定位置重复到另一个特定位置

javascript - 使用 HTML 和 CSS 修复滚动页面上的横幅

html - 如何在Struts2中并排排列两个按钮