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 trial
Mike Fondario
11,286 PointsCode Challenge - Modifying Attributes Clarification
"In jQuery add the class of 'valid' to the input with the id of 'email'."
After playing around I got this to work.
$("#email").addClass("valid");
Why is it .addClass("valid") and NOT .addClass(".valid");
1 Answer
Ilja Daderko
8,953 Pointsyou would use ".valid" in case like $(".valid") where dot "." indicates that it is a class (so not id or element). Now when you say .addClass you already specify that it is a class name, so there is no need for "." in it, what it does is searches for an element where class=".value" and I assume you want one with class="value", hence it will not work.
Mike Fondario
11,286 PointsMike Fondario
11,286 PointsThanks for the reply, great explanation.
Ilja Daderko
8,953 PointsIlja Daderko
8,953 PointsMike Fondario You are welcome :)