title: Button Toggling with JQuery & Bootstrap - How to change class of inactive after toggled
body: <p>I am using Bootstrap &amp; Jquery.</p>
  
  <p>How to change class of inactive after toggled</p>
  
  <h2>Find my code below:</h2>
  
  <p>HTML Code</p>
  
  <pre><code>    &lt;div class="btn-group btn-toggle"&gt; 
      &lt;button class="btn btn-default"&gt;Active&lt;/button&gt;
      &lt;button class="btn btn-danger active"&gt;Inacive&lt;/button&gt;
  </code></pre>
  
  <h2>        </h2>
  
  <hr>
  
  <p>SCRIPT</p>
  
  <pre><code>    $(document).ready(function(){
  
      $('.btn-toggle').click(function() {
          $(this).find('.btn').toggleClass('active');  
  
  
          if ($(this).find('.btn-danger').size()&gt;0) {
              $(this).find('.btn').toggleClass('btn-success');
              $(this).find('.btn').addClass('btn-default');
          }
          else if ($(this).find('.btn-success').size()&gt;0) {
              $(this).find('.btn').toggleClass('btn-danger');
  </code></pre>
  
  <h2>            }</h2>
  
  <p>addClass() seems not working..</p>