This week's giveaway is in the Spring forum.
We're giving away four copies of REST with Spring (video course) and have Eugen Paraschiv on-line!
See this thread for details.
The moose likes HTML, CSS and JavaScript and the fly likes Table width calculation Big Moose Saloon
  Search | Java FAQ | Recent Topics | Flagged Topics | Hot Topics | Zero Replies
Register / Login

Win a copy of REST with Spring (video course) this week in the Spring forum!
JavaRanch » Java Forums » Engineering » HTML, CSS and JavaScript
Bookmark "Table width calculation" Watch "Table width calculation" New topic

Table width calculation

Anu Jv

Joined: Apr 02, 2003
Posts: 14
I have a table with width set in percentage. Now I need to know the width of the table in pixels. Is this possible
<table width=100% border=0 id="MyTable">
<tr><td>Sample text</td></tr>
If I try "alert(document.getElementById("MyTable").width);" I get 100% but I need the width in pixels as the pixels occupied by the table will differ when the window is resized
Susilo Saja
Ranch Hand

Joined: May 27, 2003
Posts: 91
You can use the "offsetWidth" property
Anu Jv

Joined: Apr 02, 2003
Posts: 14
Thanks. It works fine
I agree. Here's the link:
subject: Table width calculation
jQuery in Action, 3rd edition