简体   繁体   English

总是显示jQuery Tipsy?

[英]Show jQuery Tipsy Always?

I am trying to use jQuery Tipsy plugin to always show tipsy onload. 我正在尝试使用jQuery Tipsy插件来始终显示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 ? 但它似乎不起作用:(任何想法我怎么能解决这个或?

In the second code segment, the images being retrieved are not related to the selector in the if statement. 在第二个代码段中,检索的图像与if语句中的选择器无关。 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. 您可以完全删除if语句。

Note that your binding tipsy to all elements matched by the selector, not just those with the 'act' link class. 请注意,您的绑定对于选择器匹配的所有元素都不及,而不仅仅是那些带有'act'链接类的元素。 If this is not your intent, add the class selector to the selector where you instantiate tipsy. 如果这不是您的意图,请将类选择器添加到您实例化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. 通常,确保您正在访问的DOM元素存在(jQuery.log消息适用于此),并且您要等到document.ready事件尝试绑定到它们。

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM