<!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()메소드는 하위 태그를 선택한다.
'JS > jQuery' 카테고리의 다른 글
.addClass() //제이쿼리(jQuery) (0) | 2020.08.01 |
---|---|
.first() //제이쿼리(jQuery) (0) | 2020.08.01 |