child element").jquery method (...)"; the greater than sign means to get the child elements under the specified element. The first-level child elements of , not all descendant elements."/> child element").jquery method (...)"; the greater than sign means to get the child elements under the specified element. The first-level child elements of , not all descendant elements.">

Home >Web Front-end >Front-end Q&A >How to use the greater than sign in jquery selector

How to use the greater than sign in jquery selector

WBOY
WBOYOriginal
2022-06-14 18:27:431998browse

In jquery, the greater than sign in the selector is used to select the child elements under the specified element. The syntax is "$("parent element>child element").jquery method (...)"; the greater than sign It means getting the first-level child elements under the specified element, not all descendant elements.

How to use the greater than sign in jquery selector

The operating environment of this tutorial: windows10 system, jquery3.6.0 version, Dell G3 computer.

How to use the greater than sign in jquery selector

>The selector matches the first-level child elements of the specified element, not all descendant elements.

Extended knowledge:

  • $(this) Current HTML element

  • ##$("p") All

  • $("p.intro") All

    elements with class="intro"

  • ##$(". intro") All elements with class="intro"
  • $("#intro") Elements with id="intro"
  • $ ("ul li:first") The first
  • element of each
    • ##$("[href$='.jpg']") All href attribute with attribute value ending in ".jpg"
    • $("div#intro .head") All in
      elements with id="intro" Elements with class="head"
    • Examples are as follows:
    • <!DOCTYPE html>
      <html>
      <head>
      <meta charset="utf-8"> 
      <title>123</title> 
      <script src="js/jquery.min.js">
      </script>
      <script>
      $(document).ready(function(){
        $("#box>div").css("background-color","green");
      });
      </script>
      <style type="text/css">
      #box{
        width:300px;
        height:200px;
        background:black;
      }
      #middle{
        width:200px;
        height:150px;
        background:red;
        margin:0px auto;
      }
      #inner{
        width:100px;
        height:100px;
        background:blue;
        margin:0px auto;
      }
      </style>
      </head>
      <body>
      <div id="box">
        <div id="middle">
          <div id="inner"></div>
        </div>
      </div>
      </body>
      </html>
      Output results:

      Video tutorial recommendation :How to use the greater than sign in jquery selectorjQuery video tutorial

The above is the detailed content of How to use the greater than sign in jquery selector. 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
Previous article:Is jquery an upgraded version of html?Next article:Is jquery an upgraded version of html?

Related articles

See more