Target Elements by Class Using jQuery

Target Elements by Class Using jQuery
0

#1

can anyone please help me how to add the shake and bouce class and tell me what is wrong with my code?

Your code so far

<script>
  $(document).ready(function() {
    $("div").addclass("animated bounce");
    $("div").addclass("animated shake");
     $("div").addclass("animated bounce");
    $("div").addclass("animated shake");
    $("button").addClass("animated bounce");
    $(".text-primary").addClass("animated shake");
  });
</script>

<!-- Only change code above this line. -->

<div class="container-fluid">
  <h3 class="text-primary text-center">jQuery Playground</h3>
  <div class="row">
    <div class="col-xs-6">
      <h4>#left-well</h4>
      <div class="well" id="left-well">
        <button class="btn btn-default target" id="target1">#target1</button>
        <button class="btn btn-default target" id="target2">#target2</button>
        <button class="btn btn-default target" id="target3">#target3</button>
      </div>
    </div>
    <div class="col-xs-6">
      <h4>#right-well</h4>
      <div class="well" id="right-well">
        <button class="btn btn-default target" id="target4">#target4</button>
        <button class="btn btn-default target" id="target5">#target5</button>
        <button class="btn btn-default target" id="target6">#target6</button>
      </div>
    </div>
  </div>
</div>

Your browser information:

Your Browser User Agent is: Mozilla/5.0 (Windows NT 6.3) AppleWebKit/537.36 (KHTML, like Gecko) Chrome/60.0.3112.90 Safari/537.36.

Link to the challenge:


#2

Below is your script. You have a lot of stuff going on with “div” elements.

<script>
  $(document).ready(function() {
    $("div").addclass("animated bounce");
    $("div").addclass("animated shake");
     $("div").addclass("animated bounce");
    $("div").addclass("animated shake");
    $("button").addClass("animated bounce");
    $(".text-primary").addClass("animated shake");
  });
</script>

The challenge starts you off with the following, so it needs to stay.

<script>
  $(document).ready(function() {
    $("button").addClass("animated bounce");
  });
</script>

The instructions say to target your div elements with the class well. If you want to target all the div elements with the class of well, then you need to put the name of the class with a dot in front of it within the $(" ") selector. You put “div” in yours several times instead of just one time with the well class.

Lastly, the instruction say to use the .addClass() again to add the classes animated and shake to the div elements with the class well.

Try this challenge again to see if you can pass now.

HINT: You will only have 3 .addClass() statements in your code. Also, remember that JavaScript is case sensitive so “addclass” is not the same as “addClass”.