moh
moh

Reputation: 1

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

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

Answers (1)

Will Metcher
Will Metcher

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

Related Questions