I am trying to add height to a div dynamically by calculating header div height and footer div height, but it's not working, Here is the example of the code:
I am looking to handle in pure javascript, no JQuery
function contentHeight(e){
var winH = document.documentElement.clientHeight;
var headerH = document.getElementsByClassName('header')[0];
var footerH = document.getElementsByClassName('footer')[0];
var contentHei = winH - headerH.clientHeight - footerH.clientHeight;
document.getElementsByClassName('content-inner')[0].clientHeight = contentHei + "px";
}
contentHeight();
<div class="header">
this is content of header
</div>
<div class="content-inner">
<!-- Apply dynamic height to this div by calculating header and footer height -->
</div>
<div class="footer">
footer content
</div>
clientHeightis read only, have you triedheight?