gpt4 book ai didi

jquery - 如何找到紧随错误跨度的 jquery 元素

转载 作者:行者123 更新时间:2023-12-01 03:19:10 25 4
gpt4 key购买 nike

我正在使用 twitter bootstrap 和 jquery 验证插件

我有一个表单行,如下所示:

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

验证后,当我在firebug中查看它时,有错误的输入后面跟着span.error。我想选择这些输入。到目前为止我已经:

$.filter(function() { return $(this).next("span.error"); })

但我收到以下错误:

类型错误:elems 未定义[中断此错误]

返回 elems.length === 1 ?

有人可以帮我吗?

谢谢

比尔

最佳答案

你试过这个吗?

$("input").filter(function() { return $(this).next("span.error").length == 1; })

关于jquery - 如何找到紧随错误跨度的 jquery 元素,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/12044689/

25 4 0
Copyright 2021 - 2024 cfsdn All Rights Reserved 蜀ICP备2022000587号
广告合作:1813099741@qq.com 6ren.com