Tek-Tips is the largest IT community on the Internet today!

Members share and learn making Tek-Tips Forums the best source of peer-reviewed technical information on the Internet!

  • Congratulations Chris Miller on being selected by the Tek-Tips community for having the most helpful posts in the forums last week. Way to Go!

Get the position of an element relative to the body or another element

Status
Not open for further replies.

Maim

Programmer
Jun 25, 1999
106
CA
I have a page with several elements, ranging from tables to inputs of type text, checkbox, button etc...

I have a div created at the start with the following properties, style="position:absolute;top:0px;left:0px;zIndex:100;visibility:hidden"

What I was trying to do is change the innerHTML of this div and position it around the page, usually over some textbox but I am not able to position it correctly. Using the offsetTop and offsetLeft properties of the textbox would return something like 2 and 3, which is the offset of the textbox within its parent.

Is there a way to get it based on the <body>? Or is it possible to position the left and top of the div to the left and top of the textbox?

Thanks in advance.

-----------------------------------
&quot;Programming today is a race between software engineers striving to build bigger and better idiot-proof programs, and the Universe trying to produce bigger and better idiots. So far, the Universe is winning.&quot; - Rich Cook
 
Status
Not open for further replies.

Part and Inventory Search

Sponsor

Back
Top