Reputation: 9855
Im trying to set the height of all my divs with class page
to 100% of the browser window...
I have the following only nothing happens and i get no errors in the console, I'm aware I could do this with jquery only my aim is to do it solely with JS.
var elements = document.querySelectorAll('page');
Array.prototype.forEach.call(elements, function(el, i){
elements.style.height = document.getElementsByTagName(window).height;
});
Upvotes: 0
Views: 133
Reputation: 5736
A couple different things wrong here:
document.getElementsByClassName
el
instead of element
in your forEach blockwindow.innerHeight
for the window heightSolution
var elements = document.getElementsByClassName('page');
Array.prototype.forEach.call(elements, function(el, i){
el.style.height = window.innerHeight+'px';
});
Upvotes: 1