javascript - Unable to get height of node -


fiddle

        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

client height jsfiddle example

docs


Comments