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 think this challenge is faulty?

Hi, guys! The question is:

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.

This is what I've done:

const $submit = $('.submit-btn');
$submit.attr('disabled', 'true');

...But the code challenge says:

Bummer! Did you supply the arguments "'disabled', true" to the "attr" method call on the variable named "$submit"?

Isn't that exactly what I've done?

2 Answers

Take true out of quotes and it should work.

But it shouldn't matter, should it?

If the true is in quotes then it will be a string instead of a boolean. I believe you have to insert a truth value. It is similar to is you have the following.

var name = "john"
print ("name")

It will not print john because name is in quotations. So when you put true in quotations you are passing in a string instead of setting disabled to true.

Still... My answer worked when I did it in Workspaces, so it shouldn't be marked wrong.

Remove the ' ' on 'true'

const $submit = $('.submit-btn'); $submit.attr('disabled', true);