javascript - qTip2 如果内容为空则隐藏

标签 javascript jquery qtip2

我从自定义标签 data-tooltip 加载工具提示文本。如果数据工具提示不存在,我希望隐藏工具提示。这可能吗?

示例 jsfiddle

最佳答案

试试这个:

$(document).ready(function() {
    $('#menu a').qtip({
        content: {
            attr: "data-tooltip"
        }
    });
});

qtip2 文档说明了使用“text”而不是“attr”:

Custom functions that return no valid content will still cause the tooltip to be created! Replace these with an each() loop if this is not the desired behaviour.

如果你看看“attr”的使用,它会说:

If no valid content is found within the elements attribute, and content.text is not defined, no tooltip will be rendered.

关于javascript - qTip2 如果内容为空则隐藏,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/10981951/

相关文章:

python - Ajax调用不调用Django中的 View 函数

javascript - 用于选项框和键入操作的 Jquery 事件

jquery - 从不隐藏 jquery qtip 工具提示

javascript - QTip 入门

javascript - 设置 React useReducer 的最佳方法

javascript - Phonegap 插件 - imagePicker - 生成错误消息

javascript - 从父窗口关闭子窗口

javascript - $.parseXML() 在 IE 8 以上的 IE 版本中不起作用

jQuery:通过 AJAX 有条件请求数据时如何返回?

javascript - qtip2模态对话框不隐藏