zoukankan      html  css  js  c++  java
  • jquery next nextAll nextUntil siblings的区别

     next:紧挨着$('')的一个元素

      nextAll:在$('')以后的所有的同辈元素

      nextUntil:until有直到。。。之前的意思,所以他表示$('')以后的所有的同辈元素,不过要在nextUntil参数之前,不包括匹配的元素本身

      sibings:$('')前后的所有同辈元素

      简单理解就是,next就是找他的弟弟/妹妹,nextAll就是找他所有的弟弟/妹妹,nextUntil就是找比他小一定年龄的弟弟/妹妹,siblings就是找他所有的哥哥/姐姐,还有他的所有的弟弟/妹妹。所以同理的同辈关系,prev,prevAll ,prevUntil 

      下面是简单的测试代码

    <!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Strict//EN" "http://www.w3.org/TR/xhtml1/DTD/xhtml1-strict.dtd">
    <html xmlns="http://www.w3.org/1999/xhtml" xml:lang="en">
    <head>
    <meta http-equiv="Content-Type" content="text/html;charset=UTF-8">
    <title>Document</title>
    <script type='text/javascript' src='http://code.jquery.com/jquery-1.9.1.min.js'></script>
    </head>
    <body>
    <div class="first">
    <a href="#">hhh</a>
    <h1>这是一个标题</h1>
    <p>这是一个test</p>
    <p>这是一个test</p>
    <p>这是一个test</p>
    <p>这是一个test</p>
    <div>hhha</div>
    <p>这是一个test</p>
    <p>这是一个test</p>
    </div>
    <script>
    $(function(){
    //$('p:first').next().css('background','red');
    //$('p:first').nextAll().css('background','yellow');
    //$('p:first').nextUntil('div').css({'font-size':20,background:'red'});
    //$('p:first').siblings().css('background','yellow');
    });
    </script>
    </body>
    </html>

  • 相关阅读:
    转:神经网络入门
    转:Webkit Flex伸缩盒模型属性备忘
    css3 display:-webkit-box
    display:inline和display:block及html常用标签
    display
    weui flex 分布
    图片、字体、iconfont矢量图
    flex weui列表demo
    方法调用
    C#多线程之Task
  • 原文地址:https://www.cnblogs.com/keanuyaoo/p/3353203.html
Copyright © 2011-2022 走看看