JavaScript jQuery Basics Working with jQuery Collections Adding/Removing Classes

I really can't figure this out

I watched the video 3 times and till don't get it!

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');
$submit.attr('submit-btn', disable);
Otec Perez Glass
Otec Perez Glass
7,678 Points

Justin Townsend Hey hope you are doing well,

<!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> 
    <!-- the class name of button is submit-btn -->

    <script
    src="jquery-3.2.1.min.js"></script>
    <script src="app.js"></script>
</body>
</html>

Also when in the Js Code

const $submit = $('.submit-btn'); 
/* when you are calling a selector by his class name remember to add a Dot at the beginning 
    Also do not forget to add the dollar $ to the Selector Not only to the constant.
*/

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

/*
attr is the DOM attribute. So you first call the constant that holds the Jquery Selector 
and then in attr  you basically set it up.
*/

1 Answer

KRIS NIKOLAISEN
KRIS NIKOLAISEN
53,537 Points

Some things:

  • line 1 is missing Jquery
  • identify a class with a period
  • line 2 the attribute is 'disabled' and is a boolean