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!

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


Testing for 'checked' values using JQuery

Code Challenge Instructions:

In jQuery add the attribute of 'checked' with the value of 'checked' to the input with the id of 'accept'

My questions is as the title asked. It is a quiz problem on jquery. I want to know why my code does not work. My code is:$("input, accept").attr("checked",true);

2 Answers


Selector to select the ID that is 'accept', then the 'attr' to add the attribute of 'checked' and the value of 'checked'.

Boolean, afaik, works with attribute as the first "value" within the brackets, then the value as the second "value".

Sorry, if that was too hard to understand.

Casey Ydenberg
Casey Ydenberg
15,622 Points

I always forget how .attr works for "boolean" attributes ...

BUT I think your selector is wrong. Input with the ID of "accept" would be $('input#accept') or just $('#accept')