我从自定义标签 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.