In jquery, ">" is a child element selector, which can only select child elements of a certain element; the syntax is "$("E > F")", where E is the parent element, and F is a sub-element, which means that all sub-elements F under the E element are selected.
The operating environment of this tutorial: windows7 system, jquery1.10.2 version, Dell G3 computer.
In jquery, ">" refers to a sub-element selector, which is a type of hierarchical selector.
Child element selector (E>F
)Only the child elements of a certain element can be selected, where E is the parent element and F is the child element, where E> What F represents is that all sub-elements F under the E element are selected.
Syntax:
$("E > F")
All selectors in jQuery begin with a dollar sign: $().
Return value: Return the matching result set
Example:
<!DOCTYPE html> <html> <head> <script type="text/javascript" src="js/jquery-1.10.2.min.js"></script> <script> $(document).ready(function() { $("#main > *").css("border", "3px double red"); }); </script> <style> body { font-size: 14px; } span#main { display: block; background: yellow; height: 110px; } button { display: block; float: left; margin: 2px; font-size: 14px; } div { width: 90px; height: 90px; margin: 5px; float: left; background: #bbf; font-weight: bold; } div.mini { width: 30px; height: 30px; background: green; } </style> </head> <body> <span id="main"> <div></div> <button>Child</button> <div class="mini"></div> <div> <div class="mini"></div> <div class="mini"></div> </div> <div><button>Grand</button></div> <div><span>A Span <em>in</em> child</span></div> <span>A Span in main</span> </span> </body> </html>
Analysis:
$ ("#main > *").css("border", "3px double red");
will match the child elements in the span element and must be the first in the child element collection An element, the following are the matching elements (purple)
[Recommended learning: jQuery video tutorial, web front-end]
The above is the detailed content of What does > in jquery mean?. For more information, please follow other related articles on the PHP Chinese website!