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 trialPierrick Le Roy
3,235 Pointsusing classList instead of className to set the 'responded' class
Hello, I think we could write it this way as well using the classList method, seems to work fine as well:
if (checked) { listItem.classList.toggle('responded'); } else { listItem.classList.toggle('responded'); }
so if checked is true, it will switch the class 'responded' on; if checked is false, it will switch 'responded' off.
1 Answer
Iain Simmons
Treehouse Moderator 32,305 PointsYes, it's a much better way of doing it, as long as you're happy to only support Internet Explorer 10 and above (which I am! :)