开发者

Using the new jQuery Position utility script at an FF extension

开发者 https://www.devze.com 2022-12-24 23:49 出处:网络
I\'m trying to use the following code at my FF extension with no success: $(\'#duck\').position({ of: \'#zebra\',

I'm trying to use the following code at my FF extension with no success:

$('#duck').position({
    of: '#zebra',
    my: "left top",
    at: "left top"
});

(the Position manual is at http://docs.jquery.com/UI/Position)

I also tried:

var doc = gBrowser.selected开发者_JAVA百科Browser.contentDocument;
$('#duck', doc).position({
    of: $('#zebra', doc),
    my: "left top",
    at: "left top"
});

Both without success.... on the other hand when I try the first code example at the web page code itself it work wonderfully...

Anyone got any idea what's causing the problem?

Cheers and thx in advance! Nimrod Yonatan Ben-Nes


use the position function like the following:

var position = $('selector').position();

var left = position.left;
var top = position.top;


In all the examples at the link you provide, they only give the id selector at the of property. Not a jqueury object..

So .. have you tried

$('#duck').position({
    of: '#zebra',
    my: "left top",
    at: "left top"
});

notice that i use '#zebra' and not $('#zebra')


sounds funny, but use double-quotes around the "left top" and "#duck" throughout. Also, be sure this is all been put within the $(document).ready function.

0

精彩评论

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

关注公众号