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

My console is telling me: "Uncaught TypeError: Cannot set property 'onchange' of null"

If someone could help me out, I would greatly appreciate it!

https://w.trhou.se/xavvr2iwuy

4 Answers

Kristopher Van Sant
PLUS
Kristopher Van Sant
Courses Plus Student 18,830 Points

Hey Rachel. Take a look at line 55 in app.js. You have a space that shouldn't be there, "input [type=checkbox]". If you remove the space after input it should fix the error message you're getting. Are you also getting an error that says "Cannot read property 'children' of undefined"?

Steven Parker
Steven Parker
231,198 Points

On line 55 of app.js, you have:

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

The space between input and [type=checkbox] makes this a descendant selector, so it's looking for an item of type "checkbox" that is a descendant of an input element. There are none, so it sets checkBox to null.

:point_right: Remove the space so it will find an input of type "checkbox".

Steven Parker
Steven Parker
231,198 Points

Heh. I took a break while composing that and someone posted something similar.

So, since it was brought up, on line 4 you have:

app.js
var completedTaskHolder;

:point_right: But you probably want:

app.js
var completedTaskHolder = document.getElementById('completed-tasks');

Those changes definitely helped!!!

But my hot mess of code still won't run. Now it's saying: Uncaught TypeError: Cannot read property 'querySelector' of undefinedbindTaskEvents

Any ideas?

Kristopher Van Sant
PLUS
Kristopher Van Sant
Courses Plus Student 18,830 Points

Yay! Glad everything's helped so far. Last thing, on line 79 you have incompleteTaskHolder instead of completedTaskHolder :)

You are totally right!!!

Now my console is saying that completedTaskHolder is undefined? This code hates everything I do!

Kristopher Van Sant
Kristopher Van Sant
Courses Plus Student 18,830 Points

Haha noooo! It doesn't hate what you're doing I promise. It's always the little things. Hmmm, I'm not sure! Double check each of the things we mentioned to change. And if you haven't removed or added anything else it should be working now. :/

So line 6 should like this ..,

var completedTaskHolder = document.getElementById("completed-tasks");

line 55

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

and line 79

for(var i = 0; i < completedTaskHolder.children.length; i++) {

If you'd like, post an updated snapshot of what you've changed so far and I'll take a look!

IT'S WORKING!!!!!!

You can't see the dance I'm doing, but it's joyous.

I forgot the "d" in complete(d)TaskHolder on line 79.

THANK YOU!!!!!!!

Kristopher Van Sant
PLUS
Kristopher Van Sant
Courses Plus Student 18,830 Points

Ahh! Hooray! So happy you figured it out! :) Haha I believe it, the "I've finally gotten the code to work!" dance is one I'm very familiar with. And again it's always those little things. Going through this just makes you that much more aware of paying attention to small details like that, so it's a great learning experience. Keep up the awesome work Rachel!