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 Traversing and Manipulating the DOM with JavaScript Perform: Traversing Elements with querySelector

Matthew Cahn
Matthew Cahn
6,301 Points

Uncaught TypeError: Cannot read property 'querySelector' of undefined

I'm getting this error for this piece of code:

var checkBox = taskListItem.querySelector("input[type=checkbox]");

is there something wrong with it?

2 Answers

You need checkbox to be in parenthesis. Try this:

var checkBox = taskListItem.querySelector("input[type='checkbox']");

Matthew Cahn
Matthew Cahn
6,301 Points

Tried it. 'fraid it didn't work. still getting the same error.

Sorry, by parenthesis I meant quotes. Anyway, the code above is working on my machine. Is there possibly an error in your HTML? Generally you should post all the code necessary to reproduce your issue. :D

Matthew Cahn
Matthew Cahn
6,301 Points

I don't know what I did but it works now. Thanks for the help.