728x90
SMALL
#jquery
#children()
.children()
.children() selects the child elements of any element.
grammar
.children( [selector] )
for example
$( 'div' ).children().css( 'color', 'blue' );
will make the color of the child elements of the div element blue.
$( 'div' ).children( 'p.bl' ).css( 'color', 'blue' );
will change the color of the p element that has bl as the class value among the child elements of the div element to blue.
example
Among the child elements of the ul element, set the color of the elements that have ip as the class value to red. The p element also has ip as its class value, but it is not a child element of the ul element, so it is not selected.
<!doctype html>
<html lang="en">
<head>
<meta charset="utf-8">
<title>jQuery</title>
<script src="//code.jquery.com/jquery-3.3.1.min.js"></script>
<script>
$( document ).ready( function() {
$( 'ul' ).children( '.ip' ).css( 'color', 'red' );
} );
</script>
</head>
<body>
<p class="ip">Amet</p>
<ul>
<li>Lorem</li>
<li class="ip">Ipsum</li>
<li>Dolor</li>
</ul>
</body>
</html>
TIP.
Use .parent() when selecting the parent element.
728x90
LIST