Home >Web Front-end >JS Tutorial >Example of usage of find() method in jQuery_jquery

Example of usage of find() method in jQuery_jquery

WBOYWBOYWBOYWBOYWBOYWBOYWBOYWBOYWBOYWBOYWBOYWBOYWB
WBOYWBOYWBOYWBOYWBOYWBOYWBOYWBOYWBOYWBOYWBOYWBOYWBOriginal
2016-05-16 16:21:481421browse

The example in this article describes the usage of find() method in jQuery. Share it with everyone for your reference. The specific analysis is as follows:

This method gets the child elements of all elements in the matching element collection and deletes them by selector, jQuery object or element.
The find() method is a good way to get descendant elements of the matching element.

Note: children() only gets first-level child elements, while find() will find all child elements.

Grammar structure 1:

Copy code The code is as follows:
$(selector).find(expr)

Parameter list:

参数 描述
expr 字符串值,定义筛选表达式。

Example code:

Copy code The code is as follows:






children() function-Script Home






I am grandson p



I am my sonp



I am a brotherp




The above code can set the font color of all p elements under the father element to red.

Grammar structure 2:

Copy code The code is as follows:
$(selector).find(element)

Can find the specified element under the matching element.

Parameter list:

参数 描述
element 用于匹配元素的DOM对象或者jQuery对象。

예제 코드:

코드 복사 코드는 다음과 같습니다.






find() 함수-스크립트 홈

나는 내 아들입니다



저는 형제입니다p


본문>

위 코드는 father 요소 아래 id 속성 값이 myp인 요소의 테두리를 1픽셀 빨간색으로 설정할 수 있습니다.

이 기사가 모든 사람의 jQuery 프로그래밍에 도움이 되기를 바랍니다.

Statement:
The content of this article is voluntarily contributed by netizens, and the copyright belongs to the original author. This site does not assume corresponding legal responsibility. If you find any content suspected of plagiarism or infringement, please contact admin@php.cn