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

William Titterton
William Titterton
10,960 Points

list items are not binding to onchange event

function bindTaskEvents(taskListItem, checkBoxEventHandler) { //cycle over incompleteTaskholeder ul list items console.log("bind list item events");

var checkBox = taskListItem.querySelector("input[type=checkbox]"); var editButton = taskListItem.querySelector("button.edit"); var deleteButton = taskListItem.querySelector("button.delete"); editButton.onclick = editTask; deleteButton.onclick = deleteTask; checkBox.onchange = checkBoxEventHandler;

//for each list item select children //bind editTask to edit button // bind to deleteButton //bind eventBoxEventHandler to checkbox

}

for (var i = 0; i < incompleteTasksHolder.children.length; i++) { bindTaskEvents(incompleteTasksHolder.children[i], complete);

}

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

bindTaskEvents(completedTasksHolder.children[i], incomplete);

}

1 Answer

Raymond Osier
Raymond Osier
16,581 Points

I had the same issue what i did to fix it was change (taskListItem) as shown in the instruction to taskList Items like this ..I Hope this helps if you have anymore questions i can try to help var bindTaskEvents = function(taskListItems, checkBoxEventHandler){ console.log("bind list items"); //selelct its children var checkbox = taskListItems.querySelector("input[type=checkbox]"); var editButton = taskListItems.querySelector("button.edit"); var deletebutton = taskListItems.querySelector("button.delete"); // bind the edit task to edit button editButton.onclick = editTask; // bind the delet task to the delete button deletebutton.onclick = deleteTask; // bind checkBoxEventHandler to the check box checkbox.onchange = checkBoxEventHandler;