- children() : 자식요소들을 선택
- children('선택자') : 자식 요소 중 선택자와 일치하는 요소를 선택
- find('선택자') : 자손 요소 중 선택자와 일치하는 요소를 선택
<!DOCTYPE html>
<html lang="en">
<head>
<meta charset="UTF-8">
<meta http-equiv="X-UA-Compatible" content="IE=edge">
<meta name="viewport" content="width=device-width, initial-scale=1.0">
<title>자손 탐색 예제</title>
<script src="../JS/jquery.min.js"></script>
<script>
$(function(){
$('.box').children().css('border-color','red');
$('.box').children('.ch1').css('border-width','5px');
$('.box').find('.link').css('background','skyblue');
})
</script>
<style>
*{ padding: 10px; list-style: none; background: white; border: 2px solid blueviolet;}
a{display: block;}
</style>
</head>
<body>
<div class="box">
box
<div class="inner-box ch1">
inner-box
<ul>
ul
<li>
li
<a href="#" class="link">메뉴1</a>
</li>
</ul>
</div>
<div class="inner-box">
inner-box
<ul>
ul
<li>
li
<a href="#" class="link">메뉴1</a>
</li>
</ul>
</div>
</div>
</body>
</html>
'괴발개발 > Javascript+JQuery' 카테고리의 다른 글
JQ_필터(탐색) (0) | 2021.06.23 |
---|---|
JQ_형제 요소 탐색 (0) | 2021.06.23 |
JQ_조상 탐색 (0) | 2021.06.23 |
JQ_길이 예제(inner,outer/Width,Height) (0) | 2021.06.23 |
JQ_CSS메소드 (0) | 2021.06.23 |