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

JavaScript

charlesporter
charlesporter
3,308 Points

Code 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
Sean Templeton
12,983 Points

When 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
Sean Templeton
12,983 Points

What is the code you are trying to use?

charlesporter
charlesporter
3,308 Points

$(input,email).addClass.("valid");

Sean Templeton
Sean Templeton
12,983 Points

look at what you are selecting. According to that, you are calling the jQuery function passing in the variables input and email.

charlesporter
charlesporter
3,308 Points

I'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
charlesporter
3,308 Points

O.K. should it look more like $(#email).addClass(“valid”);

James Barnett
James Barnett
39,199 Points

Yep that looks like valid JQuery.

charlesporter
charlesporter
3,308 Points

I used this code and it did not work $("#email").addClass("valid");

Sean Templeton
Sean Templeton
12,983 Points

That's weird, works for me. Try refreshing and trying again.

James Barnett
James Barnett
39,199 Points

That code works just fine. Did you put it in the tab labeled app.js?

charlesporter
charlesporter
3,308 Points

I did not.... Ahhh.... I actually tried that code at one point. I put it in the html file between the jQuery script tags... Ahhhhh