Reputation: 1
why my console does not recognize the getElementByClassName and getElementByTagName and querySelectorAll methods while it know getElementById and querySelector?and I can not change the style with querySelector
Upvotes: -4
Views: 80
Reputation: 311
mydoc=document.getElementsByClassName("forth");
returns a HTMLCollection object. HTMLCollection does not have a innerHTML property. You need to access a specific element of the collection through it's index. I.e.
mydoc[0].innerHTML = "change me please";
or
mydoc = document.getElementsByClassName("forth")[0];
Upvotes: 0