[英]Javascript to get height of box dynamically
I have a table which displays some grid data for search results...Now the height of this table would vary each time.我有一个表格,其中显示了一些用于搜索结果的网格数据......现在这个表格的高度每次都会有所不同。
So is there any way by which I could get the height of this dynamic table..那么有什么方法可以让我得到这个动态表的高度..
Basically I want to set an overflow:auto property for that table which would enable it to be scrolled on the iPad using 2-fingers (I cannot do the scrolling using 1-finger as that table rows does the drag action for 1-finger)基本上我想为该表设置一个溢出:自动属性,使其能够使用 2 指在 iPad 上滚动(我不能使用 1 指滚动,因为该表行执行 1 指的拖动操作)
Try:尝试:
var elem = document.getElementById("elementId");
var elemStyle = window.getComputedStyle(elem, null);
var height = elemStyle.getPropertyValue("height");
$('#tableid').height();
will get you the height (with jquery).会给你高度(用jquery)。 I'm not sure how that's relevant to your desire to use overflow:auto.我不确定这与您使用溢出:自动的愿望有什么关系。
You can get Dom element's hight using it's offsetHeight property.您可以使用它的offsetHeight属性获取 Dom 元素的高度。
声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.