简体   繁体   中英

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)

Try:

var elem = document.getElementById("elementId");
var elemStyle = window.getComputedStyle(elem, null);
var height = elemStyle.getPropertyValue("height");

You could try jQuery's height function.

$('#tableid').height(); will get you the height (with 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.

The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM