My getElementByClassName()
isn\'t returning any results, I had it set to getElementById()
, but I can\'t use the Id
since the same func
there is no such getElementByClassName()
. Try getElementsByClassName()
document.getElementsByClassName('..')
returns a set of elements while your code is written with expectation that it'll return single element. You could change that part to
var myContent = document.getElementsByClassName('content');
var num = myContent.length;
for(var x=0; x < num; x++){
myContent[x].style.display = 'block'; //or whatever style you've in your original code
}
It is getElementsByClassName instead of getElementByClassName. I would also recommend using jQuery or some sort of js framework.