jQuery 中的 nextAll( selector )方法

首页 / jQuery入门教程 / jQuery 中的 nextAll( selector )方法

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

nextAll( [selector] ) - 语法

selector.nextAll( [selector] )

这是此方法使用的所有参数的描述-

无涯教程网

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

nextAll( [selector] ) - 示例

以下是一个简单的示例,简单说明了此方法的用法-

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

这将产生以下输出-

链接:https://www.learnfk.comhttps://www.learnfk.com/jquery/traversal-nextall.html

来源:LearnFk无涯教程网

first
sibling
child
sibling
sibling

nextAll( [selector] ) - 示例

以下是一个简单的示例,简单说明了此方法的用法-

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

这将产生以下输出-

链接:https://www.learnfk.comhttps://www.learnfk.com/jquery/traversal-nextall.html

来源:LearnFk无涯教程网

first
sibling
child
sibling
sibling

祝学习愉快!(内容编辑有误?请选中要编辑内容 -> 右键 -> 修改 -> 提交!)

技术教程推荐

人工智能基础课 -〔王天一〕

Java性能调优实战 -〔刘超〕

ZooKeeper实战与源码剖析 -〔么敬国〕

分布式协议与算法实战 -〔韩健〕

软件设计之美 -〔郑晔〕

程序员的测试课 -〔郑晔〕

李智慧 · 高并发架构实战课 -〔李智慧〕

Vue 3 企业级项目实战课 -〔杨文坚〕

云原生架构与GitOps实战 -〔王炜〕

好记忆不如烂笔头。留下您的足迹吧 :)