From da78a9e329e272dedb2400b79a3bdeebff387d47 Mon Sep 17 00:00:00 2001 From: Peter Bengtsson Date: Tue, 8 Dec 2020 14:42:17 -0500 Subject: initial commit --- files/ko/web/api/node/childnodes/index.html | 51 +++++++++++++++++++++++++++++ 1 file changed, 51 insertions(+) create mode 100644 files/ko/web/api/node/childnodes/index.html (limited to 'files/ko/web/api/node/childnodes/index.html') diff --git a/files/ko/web/api/node/childnodes/index.html b/files/ko/web/api/node/childnodes/index.html new file mode 100644 index 0000000000..b57a8eabc3 --- /dev/null +++ b/files/ko/web/api/node/childnodes/index.html @@ -0,0 +1,51 @@ +--- +title: element.childNodes +slug: Web/API/Node/childNodes +tags: + - DOM + - Gecko + - Gecko DOM Reference +translation_of: Web/API/Node/childNodes +--- +

{{ ApiRef() }}

+

요약

+

childNodes는 주어진 요소의 자식 노드 모음( + + collection + )을 반환합니다.

+

구문과 값

+
var ndList = elementNodeReference.childNodes;
+
+

ndList는 현재 요소의 자식인 노드 개체의 순서 있는 모음입니다. 요소가 자식이 없으면, ndList는 아무 노드도 포함하지 않습니다.

+

ndList는 childNodes의 노드 목록을 저장하는 변수입니다. 그 목록은 NodeList 형입니다. childNodes 속성은 읽기 전용입니다.

+

+
// parg는 <p> 요소 개체 참조
+if (parg.hasChildNodes())
+// 그래서, 먼저 개체가 찼는 지(자식 노드가 있는 지) 검사
+ {
+   var children = parg.childNodes;
+   for (var i = 0; i < children.length; i++)
+   {
+   // children[i]로 각 자식에 무언가를 함
+   // 주의: 목록은 유효해(live), 자식 추가나 제거는 목록을 바꿈
+   };
+ };
+
+
// This는 노드에서 모든 자식을 제거하는 한 방법
+// box는 자식 있는 요소 개체 참조
+while (box.firstChild)
+ {
+    //목록은 유효해서(LIVE) 호출마다 재배열(re-index)함
+    box.removeChild(box.firstChild);
+ };
+
+

주의

+

노드 모음의 항목은 문자열이 아니라 개체입니다. 그 노드 개체에서 데이터를 얻으려면, 속성(예컨대 이름을 얻으려면 elementNodeReference.childNodes{{ mediawiki.external(1) }}.nodeName 등)을 써야 합니다.

+

document 개체는 자식이 둘입니다. Doctype 선언과 HTML 요소.

+

명세

+ +

{{ languages( { "en": "en/DOM/element.childNodes", "fr": "fr/DOM/element.childNodes", "pl": "pl/DOM/element.childNodes" } ) }}

-- cgit v1.2.3-54-g00ecf