Looking for a solution to this issue:
var ArrayTest = [1,2,3,4,"test"];
var ArrayTest2 = document.getElementsByClassName('mydiv');
ArrayTest2.forEach( function(){
this.style.display = 'none';
});
Although ArrayTest returns as an Array
, ArrayTest2 returns as an HTMLCollection
and forEach
results in an "undefined" type error.
Is there a way to gather an array of elements sharing the same classname and apply the same CSS to each one?