Home > Web Front-end > JS Tutorial > How to use jQuery's find() method

How to use jQuery's find() method

不言
Release: 2018-12-28 17:08:03
Original
7187 people have browsed it

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 How to use jQuerys find() methods find() method

How to use find()

It is very common to call the find method after the selector.

$(“选择器1”).find(“选择器2”).(“处理方法”);
Copy after login

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>
Copy after login

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

How to use How to use jQuerys find() methods find() method

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!

Related labels:
source:php.cn
Statement of this Website
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
Popular Tutorials
More>
Latest Downloads
More>
Web Effects
Website Source Code
Website Materials
Front End Template