JavaScript jQuery Basics Working with jQuery Collections Adding/Removing Classes

Kirblue ~
Kirblue ~
8,348 Points

There was an error with your code: Error: Syntax error, unrecognized expression: $submit

It says that there is an unrecognized expression named $submit, even though I declared a variable for it. I don't know if there is a typo or something in my code or the challenge is broken. 🤔

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')
Kirblue ~
Kirblue ~
8,348 Points

Nevermind, I found the answer right after I posted this! 😆

1 Answer

Steven Parker
Steven Parker
204,004 Points

For the benefit of other readers, the variable is fine, but it's already a jQuery object and an element selector. Also, you need to provide the value to set the property with:

$submit.attr('disabled', true);