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

Cường Nguyễn Quốc
10,910 PointsaddClass() Jquery
This is question : "The submit button is now disabled, but it doesn’t look like it! Luckily, we have a class called disabled in our CSS that will style it for us. Chain the appropriate jQuery method to add the class of disabled to the submit button." This is my answer : "var $submit = $('.submit-btn'); $submit.attr("disabled",true); $submit.addClass("disabled"); " And this is error i seen "Did you make a call to the "addClass" method after calling the "attr" method on the variable named "$submit"?" Can some body help me ?
5 Answers

Steven Parker
242,770 PointsWhen "chaining", you call more than one method in the same statement. So, for these two separate statements:
$submit.attr("disabled",true);
$submit.addClass("disabled");
The chained version would look like this:
$submit.attr("disabled",true).addClass("disabled");

Cường Nguyễn Quốc
10,910 PointsThanks bro. I don't focus on "chain". So when i read question one more, my code worked, like you comment !

dturner
6,872 Pointsnone of this works for me can anyone help me please ive been stuck on this for almost a week

Steven Parker
242,770 Pointsdturner — it might help to start a new question. Use the "get help" button if there's one on the page you are stuck on.

Khaleel Jones
13,783 PointsAre you sure this is right. I tried doing this, and it's still not working.

Steven Parker
242,770 PointsIt was right for the particular task he was working on. But since no link was given to the course page, you might be working on something with slightly different requirements. You might want to create a new question like I suggested to dturner.

Michael Furniss Sr
5,135 Pointsconst $submit = $('.submit-btn'); $submit.attr("disabled",true).addClass("disabled");

Mezut Musse
1,584 Pointsyeh i get that thanks steven, but what I mean is $submit.attr("disabled",true); $submit.addClass("disabled"); Would this also be correct for the whole objective?

Steven Parker
242,770 PointsFor practical use, those two statements would perform the same functions. But for this particular exercise, the instructions said, "Chain the appropriate jQuery method ...".

Mezut Musse
1,584 PointsThanks Steven Parker.

Mezut Musse
1,584 PointsWhat's the difference if you just said $submit.addClass("disabled"); instead of chaining the whole thing.

Steven Parker
242,770 PointsThe class only affects the appearance, but the attribute disables the button function.
Osaro Igbinovia
Full Stack JavaScript Techdegree Student 15,928 PointsOsaro Igbinovia
Full Stack JavaScript Techdegree Student 15,928 PointsPost your HTML and CSS code for better analysis.