Win a copy of Re-engineering Legacy Software this week in the Refactoring forum
or Docker in Action in the Agile forum!
  • Post Reply
  • Bookmark Topic Watch Topic
  • New Topic

Table width calculation

 
Anu Jv
Greenhorn
Posts: 14
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
Hi
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>
</table>
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
Thx
Anu
 
Susilo Saja
Ranch Hand
Posts: 91
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
You can use the "offsetWidth" property
Susilo
 
Anu Jv
Greenhorn
Posts: 14
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
Thanks. It works fine
 
  • Post Reply
  • Bookmark Topic Watch Topic
  • New Topic