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 jQuery Basics Working with jQuery Collections Adding/Removing Classes

What is and where in this lesson is the name of the attribute that we are changing to disabled?

I am asking about disabling the submit button

index.html
<!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>
app.js
var $submit = ('.submit-btn');
$submit.attr("disabled");

2 Answers

Jennifer Nordell
seal-mask
STAFF
.a{fill-rule:evenodd;}techdegree
Jennifer Nordell
Treehouse Teacher

Hi there! Your code is actually really close, but you forgot the $ sign before the selector so it never became a jQuery object. Otherwise, that selection would have been spot on. It asks you to change the disabled attribute of a button to false. There is no example in this video that I can find of that particular attribute on that particular type of HTML element. You will not find an example for every possible attribute of every possible HTML element. Instead, they are counting on you to extrapolate information from the previous examples in the video. In the video a link to a PDF file was selected and the "download" attribute was set to true. You can find this at 0:57 of the preceding video.

This challenge wants you to not select a link but rather a button and set the attribute to false. Many HTML elements have default values for attributes. A button's default disabled attribute is false. Otherwise, every button you wrote would be disabled by default and that seems less than ideal.

So in this challenge I would do:

// This selects the button with the "submit-btn" class and makes it into a jQuery object
var $submit = $('.submit-btn');
// This sets the disabled attribute to true. The button is now disabled
$submit.attr("disabled", true);

Hope this helps! :sparkles:

Good answer.Thank you. What I had trouble with was the fact that disabled is a Boolean attribute which are handled differently as in your example. Not sure how far back I had to go to find an example.