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
Post a Comment