javascript - Getting offsetTop of element in a table -


I can not seem to find how to get an element offset within a table. It works fine on the elements outside of the table, but all elements of the table have returned the same results, and this is usually at the top of the page. I tried it in Firefox and Chrome, how do I get an element offsettop in the table?

Returns a value related to offsetTop offsetParent is; You must add recursively offsetParent.offsetTop through all parents to offsetParent null . Consider using the () method.

Edit : If you do not want to use jQuery, you can type in a method like this (untested):

  Function Offset (AMM) {If (! AMM) AMM = This; Var x = elem.offsetLeft; Var y = elem.offsetTop; While (elem = elem.offsetParent) {x + = elem.offsetLeft; Y + = elem.offsetTop; } Return {left: x, above: y}; }  

Comments

Popular posts from this blog

c++ - Linux and clipboard -

What is expire header and how to achive them in ASP.NET and PHP? -

sql server - How can I determine which of my SQL 2005 statistics are unused? -