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 trialcharlesporter
3,308 PointsCode challenge issue - jQuery - .addClass
Hello internet, I am in the Build An Interactive Website –Form Validation and Manipulation – Modifying Attributes - Task 1 of 4 In “jQuery add the class of 'valid' to the input with the id of 'email' “ I cannot get an answer that will work.
8 Answers
Sean Templeton
12,983 PointsWhen ever you are trying to select elements on the DOM with jquery, selectors are passed in to the jQuery function as a string. Inside the string can be any valid CSS3 selector.
Sean Templeton
12,983 PointsWhat is the code you are trying to use?
charlesporter
3,308 Points$(input,email).addClass.("valid");
Sean Templeton
12,983 Pointslook at what you are selecting. According to that, you are calling the jQuery function passing in the variables input and email.
charlesporter
3,308 PointsI'm not sure I understand how to set up the correct foundation for these JQuery calls.... I wish there was more description for this question. Can you help frame the question a little better?
charlesporter
3,308 PointsO.K. should it look more like $(#email).addClass(“valid”);
James Barnett
39,199 PointsYep that looks like valid JQuery.
charlesporter
3,308 PointsI used this code and it did not work $("#email").addClass("valid");
Sean Templeton
12,983 PointsThat's weird, works for me. Try refreshing and trying again.
James Barnett
39,199 PointsThat code works just fine. Did you put it in the tab labeled app.js
?
charlesporter
3,308 PointsI did not.... Ahhh.... I actually tried that code at one point. I put it in the html file between the jQuery script tags... Ahhhhh