Select class control-group where none of its children are span.error

纵然是瞬间 提交于 2019-12-25 06:55:06

问题


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

易学教程内所有资源均来自网络或用户发布的内容,如有违反法律规定的内容欢迎反馈
该文章没有解决你所遇到的问题?点击提问,说说你的问题,让更多的人一起探讨吧!