JavaScript for WordPress Forums Vanilla JavaScript First attempt at innerHTML Reply To: First attempt at innerHTML

#6471
Zac Gordon
Keymaster

Hey Jon!

The reason is that getElementsByTagName returns an array.

Anything that has “elements” with the plural “s” returns an array, even if there is only one object in that array.

So if you did this it would work:


var jon = document.getElementsByTagName( 'h1' )[0];

Does that explain it?