title: Jquery, change caret class on click
body: <p>I have this html code below with the caret class <code>fa fa-caret-down</code>. Now I want that if the user clicks on the caret, the caret-down class shall gets removed and get replaced with the <code>fa fa-caret-up</code> class. And the same again, if he klicks on the caret-up class, it shall get back to the caret-down class. </p>
  
  <p>( any other way is also okay ). I've tried this: </p>
  
  <pre><code>$(document).ready(function() {
      $('.fa-caret-down').on('click', function () {
          $(this).removeClass('fa-caret-down').addClass('fa-caret-up');
      });
      $(this).removeClass('fa-caret-up').addClass('fa-caret-down');
  });
  </code></pre>
  
  <p>[ This toogle also runs very bad with this code ]</p>
  
  <p>But this only works for the first part. If I'm trying to get back to the caret-down, nothing happens. </p>
  
  <p>Thats my HTML: </p>
  
  <hr>
  
  <pre><code>&lt;div id="acc-construct" class="hidden"&gt;
      &lt;div class="acc-group"&gt;
          &lt;div class="acc-head"&gt;
              &lt;a class="acc-toggle collapsed acc-default" data-toggle="collapse"
                 data-parent="#acc" href="#collapse-divsInContainer"&gt;
                  &lt;i data-arrow="" class="pull-right fa fa-caret-down"&gt;&lt;/i&gt;
              &lt;/a&gt;
          &lt;/div&gt;
          &lt;div id="collapse-divInContainer" class="acc-body collapse"&gt;
              &lt;div class="acc-inner"&gt;
                  &lt;dl class="dl-horizontal"&gt;&lt;/dl&gt;
                  &lt;div class="separator"&gt;&lt;/div&gt;
              &lt;/div&gt;
          &lt;/div&gt;
      &lt;/div&gt;
  &lt;/div&gt;
  </code></pre>
  
  <p>I'm still new in jquery/Js and sorry for my bad english.</p>
  
  <p>Thanks for any help ! </p>