Examples of usage of find() method in jQuery
Jun 30, 2017 pm 02:06 PMThis article mainly introduces the usage of the find() method in jQuery. The function and definition of the find() method are analyzed with examples, as well as the usage skills of obtaining descendant elements of matching elements. Friends in need can refer to it
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 obtains the child elements of all elements in the matching element collection and deletes them through the selector, jQuery object or element.
The find() method is a good way to get descendant elements of the matching element.
Note: children() only obtains one-level child elements, while find() will find all child elements.
Grammar structure one:
The code is as follows:
$(selector).find(expr)
Parameter list:
The code is as follows:
<!DOCTYPE html> <html> <head> <meta charset=" utf-8"> <meta name="author" content="http://www.jb51.net/" /> <title>find()函数-脚本之家</title> <style type="text/css"> .father{ height:200px; width:200px; border:1px solid blue; } </style> <script type="text/javascript" src="mytest/jQuery/jquery-1.8.3.js"></script> <script type="text/javascript"> $(document).ready(function(){ $(".father").find(document.getElementById("myp")).css("border","1px solid red"); }) </script> </head> <body> <p class="father"> <p class="children"> <p id="myp">我是孙子p</p> </p> <p>我是儿子p</p> </p> <p>我是兄弟p</p> </body> </html>
The above code can download the father element The border of the element with id
attributeThe above is the detailed content of Examples of usage of find() method in jQuery. For more information, please follow other related articles on the PHP Chinese website!

Hot Article

Hot tools Tags

Hot Article

Hot Article Tags

Notepad++7.3.1
Easy-to-use and free code editor

SublimeText3 Chinese version
Chinese version, very easy to use

Zend Studio 13.0.1
Powerful PHP integrated development environment

Dreamweaver CS6
Visual web development tools

SublimeText3 Mac version
God-level code editing software (SublimeText3)

Hot Topics

How to use PUT request method in jQuery?

How to remove the height attribute of an element with jQuery?

jQuery Tips: Quickly modify the text of all a tags on the page

OPPO Find X7 is a masterpiece! Capture your every moment with images

OPPO Find X8 Ultra core configuration exposed! Snapdragon 8 Gen4+ Extra Large Battery

Use jQuery to modify the text content of all a tags

The relationship between the number of Oracle instances and database performance

Understand the role and application scenarios of eq in jQuery
