JavaScript jQuery Basics Working with jQuery Collections Adding/Removing Classes

jquery

helpppp

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" , true);
$submit.addClass("disabled");

1 Answer

KRIS NIKOLAISEN
KRIS NIKOLAISEN
53,693 Points

You're on the right track. You just need to chain your methods.

var $submit = $ ('.submit-btn');
$submit.attr("disabled" , true).addClass("disabled");