问题
I am working with twitter bootstrap and the jquery validate plugin
I have a form row that looks like:
<div class="form_row" >
<div class="control-group">
<label class="control-label" for="input01">home phone</label>
<div class="controls">
<input type="number" class="span4" class="input-xlarge" id="home_phone" name="home_phone" value="<?php echo $this->property->home_phone ?>" rel="popover" data-content="Re-enter your home phone." data-original-title="homephone" >
<input type="number" class="span4" class="input-xlarge" id="cell_phone" name="cell_phone" value="<?php echo $this->property->cell_phone ?>" rel="popover" data-content="Re-enter your cell_phone." data-original-title="cell_phone" >
</div>
after validation, when I look at it in firebug, the inputs with errors are followed by span.error.I would like to select class control-group where none of its children are span.error. I would appreciate any help.
Thanks , Bill
回答1:
How about:
$('.control-group').not($('.control-group span.error').closest('.control-group')).
http://jsfiddle.net/zerkms/Dhe4j/
In the jsfiddle example we select all the .control-group
which don't have nested span.error
and make them red.
来源:https://stackoverflow.com/questions/12048278/select-class-control-group-where-none-of-its-children-are-span-error