Reputation: 855
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
Thanks in advance for help
Upvotes: 2
Views: 3141
Reputation: 868
document.getElementById
doesn't return an array; just remove the [0]
on your selector.
Upvotes: 0
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