The find() method obtains the descendants of each element in the current element collection and filters them through selectors, How to use How to use jQuerys find() methods find() method objects or elements. This article will introduce you to the find() method in How to use How to use jQuerys find() methods find() method. Specific usage.
How to use find()
It is very common to call the find method after the selector.
$(“选择器1”).find(“选择器2”).(“处理方法”);
Let’s take a look at A specific example of using the find() method
We change the color of the element surrounded by the span tag
The code is as follows
<!DOCTYPE html> <html> <head> <meta charset="utf-8"> <script src="https://code.jquery.com/jquery-3.3.1.min.js"></script> <script> $(function(){ $("p").find("span").css("color","red"); }); </script> </head> <body> <p>黑色<span>红色</span>黑色<span>红色</span></p> </body> </html>
First, we use the p tag to surround the element, and then use the find method to specify the span tag and further narrow the scope of the element.
Result processing is only applied within span tags in p tags.
The operation effect is as follows
This article ends here. For more exciting content, you can pay attention to the relevant column tutorials on the PHP Chinese website to learn more! ! !
The above is the detailed content of How to use jQuery's find() method. For more information, please follow other related articles on the PHP Chinese website!