faqts : Computers : Programming : Languages : JavaScript : Tables

+ Search
Add Entry AlertManage Folder Edit Entry Add page to http://del.icio.us/
Did You Find This Entry Useful?

77 of 82 people (94%) answered Yes
Recently 8 of 10 people (80%) answered Yes

Entry

How do I find the (computed) width/height of a TABLE cell?

Apr 14th, 2000 16:14
Martin Honnen,


With IE4+ and NN6 you can read
  tableElement.offsetWidth
  tableElement.offsetHeight

Example:

<HTML>
<HEAD>
<STYLE>
.js {
  color: white;
  background-color: orange;
}
</STYLE>
<SCRIPT>
</SCRIPT>
</HEAD>
<BODY>
<TABLE BORDER="1">
<TR>
<TD ONCLICK="alert(this.offsetWidth + 'X' + this.offsetHeight)">
Kibo
</TD>
<TD CLASS="js" ONCLICK="alert(this.offsetWidth + 'X' + 
this.offsetHeight)">
JavaScript.FAQTs.com
</TD>
</TR>
</TABLE>
</DIV>
</BODY>
</HTML>