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 trialMikka Kahmann
4,802 PointsDid you declare a variable for the jQuery object with an argument of ".submit-btn"? I don't know what I'm doing wrong
Can someone help me find my mistake
<!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>
const $submit = $(".submit-btn").attr('disabled' , true);
1 Answer
Matthew Long
28,407 PointsYou definitely have the right idea! However, you're chaining the method onto the variable $submit
. This makes the variable less useful. If you call the variable and use the method on it later then the variable remains useful for other things in the future.
const $submit = $(".submit-btn");
$submit.attr("disabled", true);
If you didn't need to create a variable, you could chain it as follows with no issue:
$(".submit-btn").attr("disabled", true);
Keep in mind the challenge is asking for the variable. Hopefully this made sense and happy coding!
Julia T
2,755 PointsJulia T
2,755 PointsI made exactly the same mistake just now 😂 thank you Matthew for the clarification 🙏