Hello, I have an absolutely positioned element with top and left properties set as follows (these are defined in an external stylesheet): #my-element { position: absolute; top: 5px; left: 2px; ... } Its parent is the body element. How do I get the top and left values as numbers? I tried $(''my- element'').positionedOffset(), but that returns [0, 0] for some reason. I must be missing something simple here. Any help would be appreciated. --~--~---------~--~----~------------~-------~--~----~ You received this message because you are subscribed to the Google Groups "Ruby on Rails: Spinoffs" group. To post to this group, send email to rubyonrails-spinoffs-/JYPxA39Uh5TLH3MbocFFw@public.gmane.org To unsubscribe from this group, send email to rubyonrails-spinoffs-unsubscribe-/JYPxA39Uh5TLH3MbocFFw@public.gmane.org For more options, visit this group at http://groups.google.com/group/rubyonrails-spinoffs?hl=en -~----------~----~----~----~------~----~------~--~---
Hi, Getting the style properties is easy: http://www.prototypejs.org/api/element/getStyle That will return the style properties (e.g., with "px"). In my quick test, positionedOffset() also worked to get the computed numbers. Are you sure that when you call positionedOffset(), the DOM is loaded and the element is visible (e.g., not display: none)? Hope this helps, -- T.J. Crowder tj / crowder software / com On Apr 3, 9:49 am, Ree <rytis.daugir...-Re5JQEeQqe8AvxtiuMwx3w@public.gmane.org> wrote:> Hello, > > I have an absolutely positioned element with top and left properties > set as follows (these are defined in an external stylesheet): > > #my-element > { > position: absolute; > top: 5px; > left: 2px; > ... > > } > > Its parent is the body element. > > How do I get the top and left values as numbers? I tried $(''my- > element'').positionedOffset(), but that returns [0, 0] for some reason. > > I must be missing something simple here. Any help would be appreciated.--~--~---------~--~----~------------~-------~--~----~ You received this message because you are subscribed to the Google Groups "Ruby on Rails: Spinoffs" group. To post to this group, send email to rubyonrails-spinoffs-/JYPxA39Uh5TLH3MbocFFw@public.gmane.org To unsubscribe from this group, send email to rubyonrails-spinoffs-unsubscribe-/JYPxA39Uh5TLH3MbocFFw@public.gmane.org For more options, visit this group at http://groups.google.com/group/rubyonrails-spinoffs?hl=en -~----------~----~----~----~------~----~------~--~---
> the element is visible (e.g., not display: none)?That was it. Thanks a lot, works fine now. --~--~---------~--~----~------------~-------~--~----~ You received this message because you are subscribed to the Google Groups "Ruby on Rails: Spinoffs" group. To post to this group, send email to rubyonrails-spinoffs-/JYPxA39Uh5TLH3MbocFFw@public.gmane.org To unsubscribe from this group, send email to rubyonrails-spinoffs-unsubscribe-/JYPxA39Uh5TLH3MbocFFw@public.gmane.org For more options, visit this group at http://groups.google.com/group/rubyonrails-spinoffs?hl=en -~----------~----~----~----~------~----~------~--~---