Welcome to the Treehouse Community

Want to collaborate on code errors? Have bugs you need feedback on? Looking for an extra set of eyes on your latest project? Get support with fellow developers, designers, and programmers of all backgrounds and skill levels here with the Treehouse Community! While you're at it, check out some resources Treehouse students have shared here.

Looking to learn something new?

Treehouse offers a seven day free trial for new students. Get access to thousands of hours of content and join thousands of Treehouse students and alumni in the community today.

Start your free trial

JavaScript Interactive Web Pages with JavaScript Selecting Elements and Adding Events with JavaScript Perform: Event Handling

Gesang Lamu
Gesang Lamu
2,742 Points

getElementByTagName give error in my console

I downloaded the HMTL, CSS file and everything. So started working on my local computer but

var addButton = document.getElementByTagName("button")[0];

give an error in my console? it does not give me the first button element.

While the instructor was not getting error, i was following step by step.

What might be wrong?

Thanks,

1 Answer

You are missing the s in "Elements" Should look like:

document.getElementsByTagName("button")[0];
Gesang Lamu
Gesang Lamu
2,742 Points

OMG! thats it.... thanks!! I was looking through the HTML file

Np! Typos are easy mistakes to make and we all make them :P