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 trialLETITA BUZEA
Full Stack JavaScript Techdegree Student 4,247 PointsClicking 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.
Unsubscribed User
7,943 PointsHave you changed the event listener parameter to 'click' instead of 'mouseover'?
2 Answers
Jason Larson
8,359 PointsMake 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;
li.remove();
}
});
Stephen Cole
Courses Plus Student 15,809 PointsI found that, if mouseover
is the action type and you hover over the first item, each item moves up and triggers the event.
If you move your mouse around the list and start at the bottom, they will be deleted one at a time.
Joseph Yhu
PHP Development Techdegree Graduate 48,637 PointsJoseph Yhu
PHP Development Techdegree Graduate 48,637 PointsCould you provide us with your code so we can have a look at it?