jQuery的选择兄弟姐妹'直到' [英] jquery select siblings 'until'

查看:86
本文介绍了jQuery的选择兄弟姐妹'直到'的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我有一个

<input class="parent"></div>
<input class="child"></div>
<input class="child"></div>
<input class="parent"></div>
<input class="child"></div>
...

我知道这是不对的,正确的方法是对HTML进行修改,但是可以说这是不可能的.

which I know is not Right and the right way to do this would be to reform the HTML, but lets say that is not possible.

如何让jquery选择一个父级的所有子级(即选择所有.children直到.parent)

How can I get jquery to select all children of one parent (that is select all .children until .parent)

推荐答案

jQuery 1.4现在具有.nextUntil(selector)函数:

jQuery 1.4 now has the .nextUntil(selector) function:

    $('div.parent').toggle(
        function() {
            $(this).nextUntil('div.parent').hide();
         },
        function() {
            $(this).nextUntil('div.parent').show();
        }
    );

这篇关于jQuery的选择兄弟姐妹'直到'的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆