当前位置: 首页 > 文档资料 > jQuery 入门教程 >

nextAll([selector] )

优质
小牛编辑
112浏览
2023-12-01

描述 (Description)

nextAll( [selector] )方法查找当前元素之后的所有兄弟元素。

语法 (Syntax)

以下是使用此方法的简单语法 -

<i>selector</i>.nextAll( [selector] )

参数 (Parameters)

以下是此方法使用的所有参数的说明 -

  • selector - 可以使用CSS 1-3选择器语法编写可选选择器。 如果我们提供选择器,那么结果将被过滤掉。

例子 (Example)

以下是一个简单的例子,简单地显示了这种方法的用法 -

<html>
   <head>
      <title>The jQuery Example</title>
      <script type = "text/javascript" 
         src = "https://ajax.googleapis.com/ajax/libs/jquery/2.1.3/jquery.min.js">
      </script>
      <script type = "text/javascript" language = "javascript">
         $(document).ready(function(){
            $("div:first").nextAll().addClass("hilight");
         });
      </script>
      <style>
         .hilight { background:yellow; }
      </style>
   </head>
   <body>
      <div>first</div>
      <div>sibling<div>child</div></div>
      <div>sibling</div>
      <div>sibling</div>
   </body>
</html>

例子 (Example)

以下是一个简单的例子,简单地显示了这种方法的用法 -

<html>
   <head>
      <title>The jQuery Example</title>
      <script type = "text/javascript" 
         src = "https://ajax.googleapis.com/ajax/libs/jquery/2.1.3/jquery.min.js">
      </script>
      <script type = "text/javascript" language = "javascript">
         $(document).ready(function(){
            $("div:first").nextAll().addClass("hilight");
         });
      </script>
      <style>
         .hilight { background:yellow; }
      </style>
   </head>
   <body>
      <div>first</div>
      <div  class = "hilight">sibling<div>child</div></div>
      <div  class = "hilight">sibling</div>
      <div  class = "hilight">sibling</div>
   </body>
</html>