Dinesh
Dinesh

Reputation: 855

Cannot read property 'textContent' of undefined

I am trying to create an animated logo inspiration : http://codepen.io/pavlunya/pen/OPmVem

I am getting error when I use document.getElementById instead of document.getElementsByTagName

Jsfiddle

Thanks in advance for help

Upvotes: 2

Views: 3141

Answers (2)

Josué Zatarain
Josué Zatarain

Reputation: 868

document.getElementById doesn't return an array; just remove the [0] on your selector.

Upvotes: 0

Will P.
Will P.

Reputation: 8787

The reason p is null is because document.getElementById returns a single dom node, not an array. You do not need the [0] at the end on line 4.

Upvotes: 5

Related Questions