diff options
Diffstat (limited to 'files/ko/web/api/parentnode/children/index.html')
-rw-r--r-- | files/ko/web/api/parentnode/children/index.html | 85 |
1 files changed, 85 insertions, 0 deletions
diff --git a/files/ko/web/api/parentnode/children/index.html b/files/ko/web/api/parentnode/children/index.html new file mode 100644 index 0000000000..264fb25956 --- /dev/null +++ b/files/ko/web/api/parentnode/children/index.html @@ -0,0 +1,85 @@ +--- +title: ParentNode.children +slug: Web/API/ParentNode/children +translation_of: Web/API/ParentNode/children +--- +<div>{{ APIRef("DOM") }}</div> + +<p><span class="seoSummary">{{domxref("ParentNode")}}의 속성 <code><strong>children</strong></code>은 호출된 요소의 모든 자식 노드의 {{domxref("Element","elements")}}를 담고있는 실시간 {{domxref("HTMLCollection")}}을 반환합니다.</span></p> + +<h2 id="Syntax">Syntax </h2> + +<pre class="syntaxbox">var <em>children</em> = <em>node</em>.children;</pre> + +<h3 id="Value">Value</h3> + +<p>실시간이며, <code>node</code>의 자식 DOM 요소들의 정렬된 컬렉션인 {{ domxref("HTMLCollection") }}. 각 자식 요소를 컬렉션 안에서 접근하기 위해서 {{domxref("HTMLCollection.item", "item()")}} 메소드를 이용하거나 Javascript 배열 스타일의 문법을 사용할 수 있습니다.</p> + +<p>만약 노드가 자식요소를 갖고 있지 않나면, <code>children</code>은 0의 <code>length</code>를 가진 빈 리스트 일 것입니다.</p> + +<h2 id="Example">Example</h2> + +<pre class="brush: js">var foo = document.getElementById('foo'); +for (var i = 0; i < foo.children.length; i++) { + console.log(foo.children[i].tagName); +} +</pre> + +<h2 id="Polyfill">Polyfill</h2> + +<pre class="brush: js">// Overwrites native 'children' prototype. +// Adds Document & DocumentFragment support for IE9 & Safari. +// Returns array instead of HTMLCollection. +;(function(constructor) { + if (constructor && + constructor.prototype && + constructor.prototype.children == null) { + Object.defineProperty(constructor.prototype, 'children', { + get: function() { + var i = 0, node, nodes = this.childNodes, children = []; + while (node = nodes[i++]) { + if (node.nodeType === 1) { + children.push(node); + } + } + return children; + } + }); + } +})(window.Node || window.Element); +</pre> + +<h2 id="Specification">Specification</h2> + +<table class="standard-table"> + <tbody> + <tr> + <th scope="col">Specification</th> + <th scope="col">Status</th> + <th scope="col">Comment</th> + </tr> + <tr> + <td>{{SpecName('DOM WHATWG', '#dom-parentnode-children', 'ParentNode.children')}}</td> + <td>{{Spec2('DOM WHATWG')}}</td> + <td>Initial definition.</td> + </tr> + </tbody> +</table> + +<h2 id="Browser_compatibility">Browser compatibility</h2> + + + +<p>{{Compat("api.ParentNode.children")}}</p> + +<h2 id="See_also">See also</h2> + +<ul> + <li>The {{domxref("ParentNode")}} and {{domxref("ChildNode")}} interfaces.</li> + <li> + <div class="syntaxbox">Object types implementing this interface: {{domxref("Document")}}, {{domxref("Element")}}, and {{domxref("DocumentFragment")}}.</div> + </li> + <li> + <div class="syntaxbox">{{domxref("Node.childNodes")}}</div> + </li> +</ul> |