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
Kevin McDugle
Courses Plus Student 2,138 PointsForm Validation and Manipulation > Modifying Attributes
The question: In jQuery add the attribute of 'checked' with the value of 'checked' to the input with the id of 'accept'
My answer:
$("p input#accept").attr("checked","true");
Bummer! You need to call the 'attr' method.
I don't know what else to do? When I refresh preview it checks the box and even works!
6 Answers
J.T. Gralka
20,126 PointsKevin,
You're so close, and the answer is staring you right in the face. :-) Remember that the question is asking you to "add the attribute of 'checked' with the value of 'checked' to the input with the id of 'accept'". It seems as if you're adding an attribute of checked with a value of true, whereas, the value you need to assign to the checked attribute is checked.
See if you can modify your code to fix this issue; I retook the code challenge myself and was able to pass it using the correct value of checked.
Good luck, and let me know if you're still having issues! :-)
Best,
J.T.
Erick Castaneda
1,382 PointsCan someone explain why J.T. Gralka put a 'p' before $('input#accept') ? I used $('input#accept').attr('checked','checked'); and it worked for me. I'm just curious if adding that 'p' is semantically important.
Kevin McDugle
Courses Plus Student 2,138 Points@J.T.
Thanks for your help I corrected it like this:
$("p input#accept").attr("checked","checked");
and it WORKED, thank you!
J.T. Gralka
20,126 PointsGood stuff! Glad to be of service! :-)
Daniel Meade
Courses Plus Student 1,160 PointsI had the same trouble, you guys are lifesavers!!
Carlos Diaz
Courses Plus Student 9,006 Pointslol, I had the same issue today and for half hours was testing with no luck. So I google the how task and I found this answer. :) Thanks a lot guys
James Lines
10,420 PointsSimilar but unrelated to the question above. Why is it $('input#accept') and not $('#accept input'). I am wondering why it is the reverse of css syntax?