Turn off jQuery UI tooltip for certain elements

2019-02-04 11:27发布

For simplicity, I'd like to enable the jQuery UI tooltip widget on all elements of the page:

Then disable it for certain elements or elements and their descendants. But this doesn't seem to work:

$(document).tooltip({ track: true });
$('#menu *[title]').tooltip({ disabled: true });

My $('#menu *[title]') selector seems to work as I expect, getting all descendant elements that have a title attribute of the #menu element.

So why isn't the disabled option working in .tooltip({ disabled: true }); to disable the tooltip on those elements? Is there another way and/or better way to accomplish this?

8条回答
Animai°情兽
2楼-- · 2019-02-04 11:54

Perhaps $(':not(.menu *[title])').tooltip({ track: true });?

查看更多
▲ chillily
3楼-- · 2019-02-04 11:55

None of that worked for me and it has been driving me crazy.

This is what worked for me:

$(document).tooltip({ content: function () { return $(this).not('#NoTipDiv *[title]').attr('title'); });

$('*').tootip can heavily delay your page view!

查看更多
登录 后发表回答