JavaScript for WordPress › Forums › Vanilla JavaScript › First attempt at innerHTML › Reply To: First attempt at innerHTML
June 9, 2016 at 9:28 pm
#6471
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?