title: jQuery Validate - Add Error Class to Parent Div
body: <p>I am using the jQuery Validate plugin, and can never find a good way to display errors for checkboxes.  I'd like to highlight all of the checkbox labels in red if none are selected, and decide to do this by adding an error class to the div that contains the checkboxes and checkbox labels.  However, it doesn't seem to be adding the class.  Am I not selecting the div correctly?</p>
  
  <p>HTML:</p>
  
  <pre><code>&lt;div class="left-aligned indent"&gt;
  
      &lt;label id="id_label" for="id" class="label"&gt;Items:&lt;/label&gt;
  
      &lt;div class="select-group"&gt;
  
          &lt;input type="checkbox" name="items" value="1" id="item_1" /&gt;
          &lt;label class="checkbox"&gt;Item #1&lt;/label&gt;&lt;br /&gt;
  
          &lt;input type="checkbox" name="items" value="1" id="item_2" /&gt;
          &lt;label class="checkbox"&gt;Item #2&lt;/label&gt;&lt;br /&gt;
  
          &lt;input type="checkbox" name="items" value="1" id="item_3" /&gt;
          &lt;label class="checkbox"&gt;Item #3&lt;/label&gt;&lt;br /&gt;
  
      &lt;/div&gt;
  
  &lt;/div&gt;
  </code></pre>
  
  <p>Javascript:</p>
  
  <pre><code>$().ready(function() {
  
      $('#addForm').validate({
          rules: { 
              "items": { 
                  required: true, 
                  minlength: 1 
              } 
          }, 
          errorPlacement: function(error, element) {
              if (element.is(':checkbox')) {
                  $(this).prev("div").addClass('checkbox-error');
              }
              else {
                   return true;
              }
           }
      }); 
  
  
  });
  </code></pre>
  
  <p>CSS:</p>
  
  <pre><code>.error {
      background-color: #FF898D;
      border: 1px solid #000;
  }
  
  .checkbox-error {
      color: #FF898D;
  }
  </code></pre>