title: Jquery: Change class of Label based on check/uncheck of checkbox
body: <p>I have series of checkbox (based on user selection), I am using bootstrap CSS and want to change the class of parent (label). The following code sort of works, it changes the class but it should go back to original once unchecked. </p>
  
  <p>HTML Code:</p>
  
  <pre><code>   &lt;div class="btn-group" data-toggle="buttons"&gt;
       &lt;label for="status" class="btn btn-default"&gt;
        &lt;input type="checkbox" name="status[]" id="status" value="1"&gt; 
          &lt;span class="glyphicon glyphicon-ok"&gt;&lt;/span&gt;
       &lt;/label&gt;
     &lt;/div&gt;
  </code></pre>
  
  <p>Jquery:</p>
  
  <pre><code>     $('input:checkbox').change(function () {
         if ($(this).prop('checked', true)) {
             $(this).parent().addClass('btn btn-primary');
         } else {
            ($(this).prop('checked', false)); 
             $(this).parent().addClass('btn btn-default');
          }
        });
  </code></pre>
  
  <p>I tried few alternates, toggleClass etc but its not quite right. I am hoping once the user uncheck's it goes back to original class - btn-default. </p>
  
  <p>Here's the code on jsfiddle: <a href="http://jsfiddle.net/#&amp;togetherjs=T34b6tblRc" rel="nofollow">http://jsfiddle.net/#&amp;togetherjs=T34b6tblRc</a></p>
  
  <p>Help would be greatly appreciated, thank you! </p>