freeCodeCamp Challenge Guide: Remove Classes from an Element with jQuery

Remove Classes from an Element with jQuery


Solutions

Solution 1 (Click to Show/Hide)
<script>
  $(document).ready(function() {
    $("button").addClass("animated bounce");
    $(".well").addClass("animated shake");
    $("#target3").addClass("animated fadeOut");
    $("button").removeClass("btn-default"); //Target elements with the "button" tag and remove the class btn-default.
  });
</script>

<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>
4 Likes

Hello @camperbot , do you fix this problem I have same problem in this challenge

1 Like

$(“button”).removeClass(“animated bounce”);
$(".well").removeClass(“animated shake”);
$("#target3").removeClass(“animated fadeOut”);

$("button").removeClass("btn-default");

I already fix with this solution my friends…

What is a bit confusing is the fact that says “all button”, soo… I’m perplexed, don’t know what I’m looking for… smh…

Please help me, I have the following situation,but its not accepting it says (Only use jQuery to remove this class from the element.)

jQuery Playground

#left-well

#target1 #target2 #target3

#right-well

#target4 #target5 #target6

–>

Yes, its working, but its the same as you do math like this: 2+2+2+2+2+2 = 12 when you can do like this: 2*6=12
E.g
$(“button”).addClass(“animated bounce”);
$(".well").addClass(“animated shake”);
$("#target3").addClass(“animated fadeOut”);
$(“button”).removeClass(“btn-default”);

1 Like