开发者

Using jQuery plugins in greasemonkey (i.e. tipsy)

I'm trying (and for the most part succeeding) to use the tipsy jQuery plugin in my greasemonkey script. I am using the @require meta tag to import the jquery and tipsy js, and it works, but with a couple caveats which I'm trying to overcome.

Accessing elements as a pure jQuery object fails开发者_JS百科, so I'm relegated to using DOM functions to get my elements:

//this fails
$('#login').find('a:first').tipsy(); 

//while this succeeds
$(document.getElementById('login').getElementsByTagName('a')[0]).tipsy();

Anyone know why? Need more info? TIA!


I think it's because inside Greasemonkey, jQuery has a different default context than the document. Try this:

$("#login", document).find('a:first').tipsy();
0

上一篇:

下一篇:

精彩评论

暂无评论...
验证码 换一张
取 消

最新问答

问答排行榜