To get the top and or left position of an element do the following:
var position = $('#item1').position();
Now position.top is equal to the top and position.left is equal to the left.
So if I wanted to assign the top position to another variable I could do it
like this.
var top = position.top;
i'm sorry i still dotn think i follow entirely.
so if i had an div element with an id of item1. and i wanted to get the
position of it.
the dimensions documentation says i would do:
var position = {};
$("#myElement").position(position);
so then in this example it should be:
$("#item1").posit
Since it returns an object, you can use either dot notation or bracket
notation. So, to get the top position of an element, you could do
this ...
$(element).offset().top
or this ...
$(element).offset()['top']
hope that helps.
--Karl
_
Karl Swedberg
www.englishrules.com
However you assign it's value is how you'd reference it:
var img = $();
var top = img.top ;
is my guess.
-Original Message-
From: jquery-en@googlegroups.com [mailto:[EMAIL PROTECTED] On
Behalf Of bdee1
Sent: Thursday, May 01, 2008 2:56 PM
To: jquery-en@googlegroups.com
Subject: [jQuery]
4 matches
Mail list logo