博客
关于我
强烈建议你试试无所不能的chatGPT,快点击我
jquery 后代元素_在jQuery中查找元素的所有后代
阅读量:2531 次
发布时间:2019-05-11

本文共 1944 字,大约阅读时间需要 6 分钟。

jquery 后代元素

In this post, we are going to discuss about an important jQuery traversing method to find all the descendents of an element. jQuery API provides find() method to carry out this task.

在本文中,我们将讨论一种重要的jQuery遍历方法,以查找元素的所有后代。 jQuery API提供了find()方法来执行此任务。

jQuery find()方法 (jQuery find() method)

The jQuery find() method returns all the descendant elements like child, grandchild and so on. This method is used if you want to search all the elements deeper in the DOM tree. This method traverses downwards and finds all its descendants of the selected element. This method takes a mandatory filtering parameter to narrow down the search.

jQuery find()方法返回所有后代元素,例如child,孙子等等。 如果要搜索DOM树中更深的所有元素,则使用此方法。 此方法向下遍历并找到所选元素的所有后代。 此方法采用强制性的过滤参数来缩小搜索范围。

Here is the general syntax for using find() method:

这是使用find()方法的一般语法:

  • selector.find(filter)

    选择器。查找(过滤器)

filter is the mandatory parameter passed to the find() method. filter could be any string selector expression, an element or a jQuery object.

filter是传递给find()方法的必需参数。 filter可以是任何字符串选择器表达式,元素或jQuery对象。

jQuery find()示例 (jQuery find() example)

Following example demonstrates the jQuery find() method usage.

以下示例演示了jQuery find()方法的用法。

jQuery Traversing find

jQuery find() demo

div

p - I am div's child

span

p - I am span's Child and div's Grand Child

In this example, you can see two p elements, one element is div element’s child and the other one is it’s grandchild. The find() method finds all the p element of the selected div element and changes the color to red. Below image shows the output produced by above HTML page.

在此示例中,您可以看到两个p元素,一个元素是div元素的子元素,另一个元素是其孙子元素。 find()方法查找所选div元素的所有p元素,并将颜色更改为红色。 下图显示了以上HTML页面产生的输出。

You can use selector.find("*") to find all the descendants of the HTML document.

您可以使用selector.find("*")查找HTML文档的所有后代。

That’s all for now and you can find more traversing methods in the coming posts.

到此为止,您可以在以后的文章中找到更多的遍历方法。

翻译自:

jquery 后代元素

转载地址:http://zoqzd.baihongyu.com/

你可能感兴趣的文章
(简单)华为Nova青春 WAS-AL00的USB调试模式在哪里开启的流程
查看>>
图论知识,博客
查看>>
[原创]一篇无关技术的小日记(仅作暂存)
查看>>
20145303刘俊谦 Exp7 网络欺诈技术防范
查看>>
原生和jQuery的ajax用法
查看>>
iOS开发播放文本
查看>>
20145202马超《java》实验5
查看>>
JQuery 事件
查看>>
main(argc,argv[])
查看>>
在线教育工具—白板系统的迭代1——bug监控排查
查看>>
121. Best Time to Buy and Sell Stock
查看>>
hdu 1005 根据递推公式构造矩阵 ( 矩阵快速幂)
查看>>
安装php扩展
查看>>
百度移动搜索主要有如下几类结果构成
查看>>
Python爬虫面试题170道:2019版【1】
查看>>
JavaBean规范
查看>>
第四阶段 15_Linux tomcat安装与配置
查看>>
NAS 创建大文件
查看>>
学习笔记-模块之xml文件处理
查看>>
接口测试用例
查看>>