this question has answer here:
window.addeventlistener("resize", getsize); function getsize(){ var node = document.getelementbyid('sample'); var height = node.style.height; console.log('height: ', height);//expect 100px, nothing } #sample { padding: 20px; height: 100px; overflow-y: auto; border: solid blue; margin: 10px 300px 10px 25px; position: 'relative' }
node.style.height
empty/null. note set height 100px. why? how can css height of node?
you need use clientheight
going compute css height + css padding
Comments
Post a Comment