Tom
Tom

Reputation: 13

Show jQuery Tipsy Always?

I am trying to use jQuery Tipsy plugin to always show tipsy onload. Curently, I have something like this

jQuery('#menu li a img').tipsy({ trigger: 'manual', gravity: 'n', html: true });

And then have

if (jQuery('#menu li a').hasClass('act')) {
      jQuery('#menu li a img').tipsy('show');
    }

But it doesn't seem to work :( Any ideas how I can solve this or ?

Upvotes: 1

Views: 2933

Answers (1)

Zack Bloom
Zack Bloom

Reputation: 8427

In the second code segment, the images being retrieved are not related to the selector in the if statement. If you wish for the selector to match all links with the appropriate class add it to the selector:

jQuery("#menu li a.act img").tipsy('show')

You can remove the if statement altogether.

Note that your binding tipsy to all elements matched by the selector, not just those with the 'act' link class. If this is not your intent, add the class selector to the selector where you instantiate tipsy.

In general, make sure that the DOM elements you are accessing exist (a jQuery.log message works well for this), and that you are waiting till the document.ready event to try to bind to them.

Upvotes: 4

Related Questions