why can't i change my html content by queryselectorall and getelementbyclass name?

79 Views Asked by At

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

1

There are 1 best solutions below

0
Will Metcher On

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];