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

Vladimir Plokhotniuk
Vladimir Plokhotniuk
5,464 Points

jQuery basic

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. help me with the answer pls. Why site havent it for showinh??!

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
const $submit = $('.submit-btn').attr('disabled')

Hey, Vladmir, if you still need help on this one, you create the $submit variable and set it = to select the $(".submit-btn"). then you call it and add the .attr() method to.

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

3 Answers

Mike Hatch
Mike Hatch
14,940 Points

For me, it required two different lines of code to pass. Natalie gave you part of the missing code, but then try cutting the first line in half. First declare the variable on one line, and then add the method on the second line. (Don't forget to insert semicolons.)

Mike Hatch
Mike Hatch
14,940 Points

You're welcome. I hope you were able to pass.

Natalie Cluer
Natalie Cluer
18,898 Points

try setting "disabled" to true:

const $submit = $('.submit-btn').attr('disabled', true);
Vladimir Plokhotniuk
Vladimir Plokhotniuk
5,464 Points

'Did you declare a variable for the jQuery object with an argument of ".submit-btn"?' ... it says