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 trialEwerton Luna
Full Stack JavaScript Techdegree Graduate 24,031 PointsWhen I check the checkbox, it hides the li correctly, but when I uncheck, the items are not displayed back again.
My code is exactly equal to Guil's (or I think it is).
filterCheckbox.addEventListener('change', (event) => {
const isChecked = event.target.checked;
const lis = ul.children;
if (isChecked) {
for (let i = 0; i < lis.length; i += 1) {
let li = lis[i];
if (li.className === 'responded') {
li.style.display = '';
}
else {
li.style.display = 'none';
}
}
} else {
for (let i = 0; i < lis.length; i += 1) {
let li = lis[i];
li.style.display = '';
}
}
});
Why is it not working properly? Am I missing something?
3 Answers
KRIS NIKOLAISEN
54,971 PointsYou have filterCheckbox.addEventListener twice in your code. The second one doesn't have an else statement but should be deleted anyways.
KRIS NIKOLAISEN
54,971 PointsYou may have to post more code - or better yet a snapshot. I tried your code and it worked. It's not exactly the same in that the B in Box of filterCheckBox is uppercase, but that would have produced a different error. Is there anything in the console and can you post a snapshot?
Ewerton Luna
Full Stack JavaScript Techdegree Graduate 24,031 PointsAnder Bil
Full Stack JavaScript Techdegree Student 6,480 PointsI have the same problem. hides everything correctly and then it does not work after the first click. I does not show any error on the console.