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

Zac Gordon

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?