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; If you only needed the top you could simply just do the following. var top = $('#item1').position().top; Here are the docs for dimensions 1.2: http://docs.jquery.com/Plugins/dimensions -- Brandon Aaron On Fri, May 2, 2008 at 10:04 AM, bdee1 <[EMAIL PROTECTED]> wrote: > > > 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").position(position); > > then to access the top position, i woudl do the following? > $("#item1").offset().top > > is that correct? > > > > Karl Swedberg-2 wrote: > > > > > > > > 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 > > www.learningjquery.com > > > > > > > > On May 1, 2008, at 3:56 PM, bdee1 wrote: > > > >> > >> > >> i am a little unclear on how exactly to get the position of an > >> element using > >> jquery dimensions plugin. > >> > >> documentation says it returns "An object with top and left > >> properties that > >> are numbers representing the offset in pixels." > >> > >> and it says the object looks like this: > >> { top: 10, left: 10 } > >> > >> so how do i access it? like a string? do i have to use string > >> functions to > >> pull out the height and width individually? > >> -- > >> View this message in context: > >> http://www.nabble.com/dimensiosn-plugin-tp16995030s27240p16995030.html > >> Sent from the jQuery General Discussion mailing list archive at > >> Nabble.com. > >> > > > > > > > > -- > View this message in context: > http://www.nabble.com/dimensiosn-plugin-tp16995030s27240p17021373.html > Sent from the jQuery General Discussion mailing list archive at > Nabble.com. > >