I’m trying to run the following code on a website to set up the height of elements in a webpage:
document.querySelector("#body").style.height = window.innerHeight - document.querySelector("#footer").offsetHeight;
It’s part of a function, and all the other parts of the function appear to be working properly, but this section does not work.
A similar command however, written with jQuery, does work:
$("#body").css({ "height" : window.innerHeight - document.querySelector("#footer").offsetHeight });
But I’d rather not have to call on the jQuery library for something as small as this.
Any suggestions as for what I’m doing wrong?
try to append ‘px’ at the end of the computed value.