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 trialShaun Wong
14,489 PointsSelect the submit button by its class and save it to a variable called $submit....
Challenge Task 1 of 2 Select the submit button by its class and save it to a variable called $submit. Then use the appropriate jQuery method to disable the button by adding a disabled attribute to it.
Will not validate, what have i done wrong here?
<!DOCTYPE html>
<html lang="en">
<head>
<title>Document</title>
<link rel="stylesheet" href="style.css">
</head>
<body>
<button type="submit" class="submit-btn">Submit If You Can</button>
<script
src="jquery-3.2.1.min.js"></script>
<script src="app.js"></script>
</body>
</html>
var $submit = $('.submit-btn');
$submit.attr("disabled","true");
4 Answers
Shaun Wong
14,489 PointsOh hang on, I see. True should not be in " quotes " as it's not a string but a boolean. However. I may have gotten confused when I was browsing and saw .attr("disabled", "disabled");
The error that came up told me to use true instead but would not validate.
Nevertheless... Answer below for anyone who gets stuck.
var $submit = $('.submit-btn');
$submit.attr("disabled",true);
Terri Valentine
23,034 PointsThank you Shaun Wong. I had been stuck on that one for several days.
Sean Flanagan
33,235 PointsThank you Shaun. That's a big help!
dturner
6,872 Pointsnot-porn-app.js?????
Randell Purington
9,992 PointsThank you for the help, but I am wondering what other app.js there are.lol
Zachary Danz
Front End Web Development Techdegree Graduate 15,024 PointsYou saved me too mate, thanks a ton
Christian Higgins
15,758 PointsYep! Same mistake here. Thanks!
Midhun Chandran
9,414 Pointsconst $submit = $('.submit-btn'); $submit.attr("disabled",true);
The above worked for me. It is same as what shaun wong suggested. The only difference being that i used const instead of var.
Hope this helps. Thanks!
Nnanna Okoli
Front End Web Development Techdegree Graduate 19,181 PointsI got everything right except for using the word "const" instead of "var"
However, both codes were passed! (eg.) const $submit = $('.submit-btn') $submit.attr("disabled", true);
I would like to add that Treasure Porth's teachings is like a breath of fresh air as she is the light at the end of the tunnel lol.. keep going guys. Lastly, if someone could help why both codes were passed AND why would we need to use 'var' instead of 'const' to save our change to a variable?
Shaun Wong
14,489 PointsShaun Wong
14,489 PointsI tried .attr("disabled", "disabled");
as well.