Welcome to the Treehouse Community

The Treehouse Community is a meeting place for developers, designers, and programmers of all backgrounds and skill levels to get support. Collaborate here on code errors or bugs that you need feedback on, or asking for an extra set of eyes on your latest project. Join thousands of Treehouse students and alumni in the community today. (Note: Only Treehouse students can comment or ask questions, but non-students are welcome to browse our conversations.)

Looking to learn something new?

Treehouse offers a seven day free trial for new students. Get access to thousands of hours of content and a supportive community. Start your free trial today.

JavaScript Interacting with the DOM Traversing the DOM Traversing up the DOM with parentNode

Full Stack JavaScript Techdegree Student 3,928 Points

Clicking on one of the list items makes them all disappear

I wrote the code as instructed in the video. The buttons work, but the list items disappear all at once if I click on one of them.

Alin Andrei Gheorghe
Alin Andrei Gheorghe
6,367 Points

Have you changed the event listener parameter to 'click' instead of 'mouseover'?

1 Answer

Jason Larson
Jason Larson
7,174 Points

Make sure in the taskList.addEventListener function that you change your if statement to look for the tagName button instead of LI, as below.

taskList.addEventListener("click", (event) => {
    if (event.target.tagName == "BUTTON") {
        let button = event.target;
        let li = button.parentNode;