Howdy, Stranger!

It looks like you're new here. If you want to get involved, click one of these buttons!

.get when no tooltip exist for an element

I'm using .get(".btn") with element specified and want to check if tooltip was already created for that element.
But I always get something back if there are other tooltips on the page.

Am I using it incorrectly? Can I tell if element has tooltip already attached to it or not?

version: 4.2.5



  • edited October 2015
    ".btn" is a class selector, it selects multiple elements, use an id instead or make the selector more specific to target just one element.

    Tipped.get() by itself doesn't check for tooltips, it always returns a collection even if it's empty. There's an internal method you could use to test for tooltips, but I don't recommend using it since it's not documented, meaning it might stop working at some point:

    Tipped.get("#id").items().length > 0 // true if a tooltip exists

    Instead if you are calling Tipped.create() multiple times on the same element and want only one tooltip, simply remove previous tooltips before calling Tipped.create():
    Tipped.create("#id", "text");
    Also I recommend upgrading to the latest version.
  • Hi Nick!
    Thanks for swift reply.
    Sorry, that was just an example, I use id selector.

    Ok, so no official way?
    Would be great to have one.

    I'll check out the new version, thanks!

Sign In or Register to comment.