Q: Find class anywhere in div's descendants I have a Bootstrap accordion/well with form elements in each accordion section. As a user navigates through the different fields and accordion sections, I would like a span to appear based on whether or not they filled out all the required data. All the input fields sit within .section. If a user doesn't fill out a required field, the .form-group around the input and label gets the class .has-error. When they fix the issue, .has-error is replaced with .no-error.
So if the .has-error class appears anywhere in .section (all descendants including grandchildren), the span .field-error should appear in .lbl.lblBig, which is the sibling immediately before .section and contains the title for that accordion's section. If .has-error isn't anywhere in sight, then I want the span .field-ok to show inside .lbl.lblBig.
Here's rudimentary layout:
 <div class="lbl lblBig">
      Section 1
      <span class="field-error" style="display:none"></span>
      <span class="field-ok" style="display:none"></span>
 </div>
 <div class="section"> <!--input fields for section 1-->
      <div class="form-group">
           <label class="control-label">First</label>
           <input class="required form-control" placeholder="First">
      </div>
      <div class="form-group">
           <label class="control-label">Last</label>
           <input class="required form-control" placeholder="Last">
      </div>
 </div>
 <div class="lbl lblBig">
      Section 2
      <span class="field-error" style="display:none"></span>
      <span class="field-ok" style="display:none"></span>
 </div>
 <div class="section"> <!--input fields for section 2-->
      <div class="form-group">
           <label class="control-label">Street</label>
           <input class="required form-control" placeholder="Street">
      </div>
      <div class="form-group">
           <label class="control-label">City</label>
           <input class="required form-control" placeholder="City">
      </div>
 </div>

I've put together this script, but it doesn't work. I don't need the .no-error class, but I created it in an attempt to get something working. I'm having trouble searching through .section's decedents and using that info to change .lbl.lblBig.
$(".section").each(function(){
    if ($(this).find(".has-error").length) {
        $(this).prev(".lbl.lblBig").find(".field-error").show();
        $(this).prev(".lbl.lblBig").find(".field-ok").hide();
    }
    else if ($(this).find(".no-error").//do opposite of length? ) {
        $(this).prev(".lbl.lblBig").find(".field-error").hide();
        $(this).prev(".lbl.lblBig").find(".field-ok").show();
    }
});

I can't change any of the page's and form's HTML, so I'm limited in that regard. Any help would be greatly appreciated. If I could, I would bake you a cookie, but this is the internet, and there is no 3D print-baking technology. Thank you.

A: Your condition expression should be if (length > 0).
$(".section").each(function(){
    if ($(this).find(".has-error").length > 0) {
        $(this).prev(".lbl.lblBig").find(".field-error").show();
        $(this).prev(".lbl.lblBig").find(".field-ok").hide();
    }
    else {
        $(this).prev(".lbl.lblBig").find(".field-error").hide();
        $(this).prev(".lbl.lblBig").find(".field-ok").show();
    }
});

http://jsfiddle.net/9dbyq2v3/
