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')
Gremyko Coleman
Gremyko Coleman
6,281 Points

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

Natalie Cluer
Natalie Cluer
18,887 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

Mike Hatch
Mike Hatch
14,939 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,939 Points

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