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 trialMichael Lyell
45 PointsI do not understand the const checked = checkbox.checked..
where is the ".checked" coming from It isn't declared anywhere
2 Answers
Victor Mercier
14,667 PointsHi, so what is happening is that you are using the check property on a DOM element. This property is going to return either true or false (true when your checkbox is checked, false when your checkbox is unchecked).
I hope it helped you, if yes, please mark as best answer! Happy Coding!
Doron Geyer
Full Stack JavaScript Techdegree Student 13,897 PointsPerhaps this would be simpler and help with understanding :
ulInvitedList.addEventListener("change", (e)=>{
if(e.target.checked){
e.target.parentNode.parentNode.className ="responded"
}
if(e.target.checked == false){
e.target.parentNode.parentNode.className = '';
}
})
as you can see from my code above. Checked is used as a boolean to show whether or not the checkbox is infact "checked"
if there were radio buttons included then you would be able to resolve it as follows
ulInvitedList.addEventListener("change", (e)=>{
if(e.target.type=="checkbox"){
if(e.target.checked){
e.target.parentNode.parentNode.className ="responded"
}
if(e.target.checked == false){
e.target.parentNode.parentNode.className = '';
}
}
})