Difference between offsetParent and parentElement or parentNode
I have a following DOM structure <body> <div> <table> <outerElement> <innerElement /> </outerElement> <table> </div> </body> DIV has its overflow set to auto so if table grows bigger - it scrolls within the DIV. In this scenario why table.offsetParent returns the body while both table.parentNode and parentElement return the Div? I need to calculate current position of the innerElement within the window, so I traverse from it up thru all parent elements, collecting their offsetTop and offsetLeft values. Up until the DIV offsetParent works fine and then it skips it directly to the body. The