How can I calculate the rendered height of an HTML table, from within JavaScript?

谁说我不能喝 提交于 2019-12-10 20:04:58

问题


When the window is resized, I need to know how big the table is, so I can dynamically fit everything else nicely in-between. The table height is solely dependant on the contents, which are loaded dynamically. How do you calculate the rendered height of the table in JavaScript?


回答1:


You can use element.offsetHeight for this.

var table = document.getElementById("tableId");
alert(table.offsetHeight);


来源:https://stackoverflow.com/questions/2733666/how-can-i-calculate-the-rendered-height-of-an-html-table-from-within-javascript

易学教程内所有资源均来自网络或用户发布的内容,如有违反法律规定的内容欢迎反馈
该文章没有解决你所遇到的问题?点击提问,说说你的问题,让更多的人一起探讨吧!