kevin
kevin

Reputation: 467

Testing to see if a jQuery UI Tooltip is open

I'm trying to control the automatic opening and closing of a jQuery Tooltip.

How do I test to see if the current status of a tooltip is open?

I'm using the most recent versions of everything.

Thanks!

Upvotes: 5

Views: 6319

Answers (1)

Praveen Kumar Purushothaman
Praveen Kumar Purushothaman

Reputation: 167240

You can try by checking if there are any classes with ui-tooltip.

$(".ui-tooltip").length

Or, alternatively, you can use the API to check if it is open. You can set a flag and check using:

$(".selector").on("tooltipopen", function(event, ui) {
    $(this).data("tooltip", true);
});
$(".selector").on("tooltipclose", function(event, ui) {
    $(this).data("tooltip", false);
});

To know the current status of the tooltip, you can use this:

$(".selector").data("tooltip");

It returns true if open, and false if closed. Hope this helps...

Upvotes: 7

Related Questions