Description: Get the ancestors of each element in the current set of matched elements, up to but not including the element matched by the selector, DOM node, or jQuery object.

获得当前匹配元素集合中每个元素的祖先元素,直到(但不包括)被选择器、DOM 节点或 jQuery 对象匹配的元素。

.parentsUntil( [selector] [, filter] )

.parentsUntil( [element] [, filter] )

Given a selector expression that represents a set of DOM elements, the .parentsUntil() method traverses through the ancestors of these elements until it reaches an element matched by the selector passed in the method's argument. The resulting jQuery object contains all of the ancestors up to but not including the one matched by the .parentsUntil() selector.

If the selector is not matched or is not supplied, all ancestors will be selected; in these cases it selects the same elements as the .parents() method does when no selector is provided.

Example:

<ul class="level-1 yes">
<li class="item-i">I</li>
<li class="item-ii">II
<ul class="level-2 yes">
<li class="item-a">A</li>
<li class="item-b">B
<ul class="level-3">
<li class="item-1">1</li>
<li class="item-2">2</li>
<li class="item-3">3</li>
</ul>
</li>
<li class="item-c">C</li>
</ul>
</li>
<li class="item-iii">III</li>
</ul>
<script>
$("li.item-a").parentsUntil(".level-1")
.css("background-color", "red"); $("li.item-2").parentsUntil( $("ul.level-1"), ".yes" )
.css("border", "3px solid green"); </script>

中文文档:http://www.w3school.com.cn/jquery/traversing_parentsuntil.asp

相关的还有:nextUtil jQuery 参考手册 - 遍历

最新文章

  1. Python 实现粒子滤波
  2. B0BO TFS 安装指南(转载)
  3. C# eval()函数浅谈
  4. Deep Learning 学习随记(七)Convolution and Pooling --卷积和池化
  5. Django学习(六) 模板
  6. eclipse使用技巧---使用正则表达式查找替换
  7. mobile&amp;nbsp;web&amp;nbsp;手机开发
  8. JS的运算问题……
  9. linux 内核的rt_mutex (realtime互斥体)
  10. 【Unity3D与23种设计模式】享元模式(Flyweight)
  11. javascript基础之函数
  12. java递归删除文件夹
  13. 一种使用 emwin 绘制图片的方法
  14. UI基础七:给普通其他界面的PRODUCT 添加标准的搜索帮助
  15. windows 运行hadoop的WordCount报nativeio.NativeIO$Windows.createDirectoryWithMode0(Ljava/lang/String;I)
  16. 虚拟机中的CentOS 7设置固定IP连接最理想的配置
  17. leetcode367
  18. AES CFB/OFB/ECB/CBC/CTR优缺点
  19. python-多进程类封装
  20. [CTSC2012]熟悉的文章 后缀自动机

热门文章

  1. 个人项目:wc程序(java)
  2. WPF 控件库——轮播控件
  3. Java读写配置文件prop.properties
  4. oracle调试存储过程不进去
  5. MyBatis与Hibernate比较
  6. 启动Tomcat报错
  7. C++_友元3-其他友元关系
  8. [洛谷 P4612][COCI 2011-2012#7] Setnja
  9. python (1) 还不是大全的小问题
  10. hash &amp; heap - 20181023 - 20181026