프로그램
jQuery find() Method
다온다올과함께
2021. 12. 31. 14:45
The find() method returns descendant elements of the selected element.
(find() 메서드는 선택한 요소의 하위 요소를 반환합니다.)
html
<div class="a">
<span class="s1">Lorem</span>
<span class="s2">Ipsum</span>
<span class="s3">Dolor</span>
</div>
<div class="b">
<span class="s1">Lorem</span>
<span class="s2">Ipsum</span>
<span class="s3">Dolor</span>
</div>
css
.color {
color:red;
font-size:2em;
font-weight:bold;
}
Jquery
$( '.a' ).find( 'span.s2' ).css( 'font-size', '2em');
$( '.b' ).find( 'span.s3' ).addClass('color');
Result(결과)

반응형