Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

Turn off jQuery UI tooltip for certain elements

Tags:

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?

like image 519
slolife Avatar asked Oct 30 '12 17:10

slolife


People also ask

How do I enable and disable tooltips in jQuery?

$(document). tooltip("disable"); $(document). tooltip("enable");

How to position tooltip jQuery?

The tooltip position is specified with two different configuration properties: position and offset . The position property specifies the position in relation to the trigger element. For example, a value of 'bottom center' will place the tooltip on the bottom edge of the trigger, centered horizontally.

What is tooltip function in jQuery?

The jQuery UI tooltip() method adds tooltip to any element on which you want to display tooltip. It gives a fade animation by default to show and hide the tooltip, compared to just toggling the visibility. Syntax: You can use the tooltip() method in two forms. $(selector, context).tooltip (options) Method.


2 Answers

Set tooltip on all elements with:

$('*').tooltip(); 

And disable with

$('#menu *[title]').tooltip('disable'); 

A la:

jsFiddle

like image 141
Elliott Avatar answered Sep 24 '22 13:09

Elliott


None of the answers above worked for me, it seems like the way to do this now is to use the items option:

$("*").tooltip({ items: ':not(.menu)' }); 
like image 25
Quails4Eva Avatar answered Sep 21 '22 13:09

Quails4Eva