How do I get/read/manipulate an elements position?

Collapse
X
 
  • Time
  • Show
Clear All
new posts
  • bushnellweb
    New Member
    • Jan 2010
    • 48

    #1

    How do I get/read/manipulate an elements position?

    OK, heres the deal...I know how to document.getEle mentById('id'). style.position and .top and .left. My question refers to the elements position on the page how the client sees it. for example: I need to find the .top of an element that has been placed inline and has no set .top. Is there like an absolute x or y position I can look at?
  • johny10151981
    Top Contributor
    • Jan 2010
    • 1059

    #2
    This is a javascript question.

    If your object position is not absolute you cannot get object position by left and top style.

    you need to use
    obj.offsetLeft obj.offsetRight

    follow the link to get some good solution link

    Comment

    • gits
      Recognized Expert Moderator Expert
      • May 2007
      • 5390

      #3
      here are some useful additional explainations to the already mentioned solution.

      kind regards

      Comment

      • gumape
        New Member
        • Aug 2010
        • 2

        #4
        The offsetLeft and offsetTop properties return the left and top positions of an object relative to the left and top sides of its offsetParent element. If you need the position of an element relative to the upper-left corner of the browser's client area, use the getBoundingClie ntRect method instead.
        You can find detailed description and examples on the following pages:
        getBoundingClie ntRect,
        offsetLeft

        Comment

        Working...