How to get the height in pixels in pure javascript? -


i have got forum following html structure:

<div id="header">contents</div> <div id="main">contents</div> <div id="footer">contents</div> 

basically, need set height of #main height of document minus height of other 2 elements. problem have without jquery.i googled problem , found clientheight method, returns height number, while need pixels.

so, question is:is there way height in pixels in pure javascript?

clientheight return number pixel value.

add calculated value , add +"px" @ end of it.

the code want set hight of div#main below

document.getelementbyid('main').style.height=(parseint(window.innerheight) -  (document.getelementbyid('header').clientheight +   document.getelementbyid('footer').clientheight))+"px";
<div id="header">contents</div>  <div id="main">contents</div>  <div id="footer">contents</div>


Comments

Popular posts from this blog

php - Vagrant up error - Uncaught Reflection Exception: Class DOMDocument does not exist -

vue.js - Create hooks for automated testing -

Add new key value to json node in java -