Home  >  Article  >  Web Front-end  >  How to use jQuery’s find() method

How to use jQuery’s find() method

不言
不言Original
2018-12-27 17:06:067086browse

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 jQuery’s find() method’s find() method objects or elements. This article will introduce you to the find() method in How to use How to use jQuery’s find() method’s find() method. Specific usage.

How to use How to use jQuery’s find() method’s find() method

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

How to use How to use jQuery’s find() method’s 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!

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