【问题标题】:how to select class where a child has a specific class, in jquery如何在jquery中选择孩子有特定班级的班级
【发布时间】:2012-08-21 02:07:18
【问题描述】:

我正在使用 twitter bootstrap 和 jquery validate 插件

我有一个看起来像这样的表单行:

<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>

验证后,当我在firebug中查看它时,有错误的输入后面是span.error。我想选择具有子项的 .control-group div,这些子项是 span.error

          $(".control-group").filter(function() { return !($(this).children().('span.error'))})

这似乎不起作用。任何人都可以让它工作吗?

提前致谢,

比尔

【问题讨论】:

    标签: jquery jquery-plugins twitter-bootstrap jquery-validate


    【解决方案1】:
    $('span.error').parents('.control-group')
    

    这将选择页面上任何具有“控制组”类的项目,该项目在其内部的任何地方都有一个“错误”类。

    【讨论】:

      猜你喜欢
      • 1970-01-01
      • 2014-01-01
      • 1970-01-01
      • 1970-01-01
      • 1970-01-01
      • 2018-08-11
      • 2017-03-18
      • 1970-01-01
      • 1970-01-01
      相关资源
      最近更新 更多