본문 바로가기

프로그램/JQUERY

jquery children() 함수

반응형

children() 은 지정한 엘리먼트의 바로 아래 자식 노드들을 찾아서 순회하는데 사용됩니다.

아래 샘플 소스를 보면 id 가 root인 엘리먼트의 자식 노드의 갯수를 보여줍니다.

 

<script >
$(document).ready(function(){
var $nodes = $('#root').children();
alert($nodes.length);

var txt = '' ;
$('#root').children().each(function(){
txt+=$(this).text();
});
alert(txt);
});
</script>
</HEAD>

<BODY>
<div id="root">
<div>test</div>
<div>확인</div>
</div>
</BODY>
</HTML>

반응형

'프로그램 > JQUERY' 카테고리의 다른 글

$(document).read(function())  (0) 2013.07.30
jquery $() 함수  (0) 2013.07.29
jquery 설정 방법  (0) 2013.07.19
jquery js 다운로드  (0) 2013.07.18