JavaScript jQuery Basics Working with jQuery Collections Adding/Removing Classes

Mark Wisdom Reeves
seal-mask
.a{fill-rule:evenodd;}techdegree seal-36
Mark Wisdom Reeves
Full Stack JavaScript Techdegree Graduate 18,275 Points

Select the submit button by its class and save it to a variable called $submit. Then use the appropriate jQuery method t

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

<!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>

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
$submit = $(".submit-btn");
$submit.attr("disabled", "disabled");

1 Answer

Elijah Quesada
seal-mask
.a{fill-rule:evenodd;}techdegree seal-36
Elijah Quesada
Front End Web Development Techdegree Graduate 32,961 Points

First thing you gotta do is declare var $submit. Then the second argument in the attr property will be true.

var $submit = $(".submit-btn");
$submit.attr("disabled", true);
```js