JS/jQuery
.find() //제이쿼리(jQuery)
싸공
2020. 8. 1. 09:14
<!doctype html>
<html lang="en">
<head>
<meta charset="utf-8">
<title>find demo</title>
<script src="https://code.jquery.com/jquery-3.5.0.js"></script>
</head>
<body>
<p>
<span>Hello</span>
World
</p>
<p>Hello
<span>jquery</span>
</p>
<hr>
<div>
<div class="container">
<ol>
<li class="box1">A</li>
<ul>
<li class="box2">a-1</li>
<li>a-2</li>
<li>a-3</li>
</ul>
<li>B</li>
<li>C</li>
</ol>
</div>
</div>
<script>
$( "p" ).find( "span" ).css( "background-color", "yellow" );
$( "div.container" ).find( ".box1" ).css( "background-color", "red" );
$( "div.container" ).find( ".box2" ).css( "background-color", "yellow" );
</script>
</body>
</html>
find()메소드는 하위 태그를 선택한다.