" 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 the child element. It means that all sub-elements F under the E element are selected."/> " 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 the child element. It means that all sub-elements F under the E element are selected.">

Home  >  Article  >  Web Front-end  >  What does > in jquery mean?

What does > in jquery mean?

青灯夜游
青灯夜游Original
2022-02-28 15:49:532264browse

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.

What does > in jquery mean?

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)

What does > in jquery mean?

[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!

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