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

I can't figure it out!

In jQuery add the class of 'valid' to the input with the id of 'email'

Recheck Work Bummer! You need to call the 'addClass' method.

app.js

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

.addClass();

How do I call the 'addClass method?

3 Answers

You're almost there, you just need to change your selector slightly:

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

That selects the following element:

<input id="email">

Whereas:

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

Would select this for example:

<div id="email">
    <input>
</div>

Belle - If you are still confused, you might be interested in checking out this great tutorial, for a little review on descendant selectors


Friendly Mod Note :tm: - In the future you might want to consider using a more descriptive title

sup james