pm1122dev의 비밀노트

[Jquery] 자식요소 찾기 children() 본문

javascript&jquery

[Jquery] 자식요소 찾기 children()

pm1122Dev 2021. 4. 26. 22:54
728x90
반응형

api.jquery.com/children/#children-selector

 

.children() | jQuery API Documentation

Description: Get the children of each element in the set of matched elements, optionally filtered by a selector. Given a jQuery object that represents a set of DOM elements, the .children() method allows us to search through the children of these elements

api.jquery.com

children()은 자식 선택된 요소의 자식요소를 반환합니다. 

간단한 예를 보시면 이해가 가실겁니다. 

 

html

<div class="parent">
	<p class="child">자식요소</p>
</div>

jquery

$(function(){
	childEl = $(".parent").children();
    console.log(childEl);
    
    //결과
    <p class="child">자식요소</p>
})
728x90
반응형
Comments