aboutsummaryrefslogtreecommitdiff
path: root/files/ko/web/api/document/createelement/index.html
diff options
context:
space:
mode:
Diffstat (limited to 'files/ko/web/api/document/createelement/index.html')
-rw-r--r--files/ko/web/api/document/createelement/index.html101
1 files changed, 101 insertions, 0 deletions
diff --git a/files/ko/web/api/document/createelement/index.html b/files/ko/web/api/document/createelement/index.html
new file mode 100644
index 0000000000..6cb461eeb5
--- /dev/null
+++ b/files/ko/web/api/document/createelement/index.html
@@ -0,0 +1,101 @@
+---
+title: Document.createElement()
+slug: Web/API/Document/createElement
+tags:
+ - API
+ - DOM
+ - Document
+ - Method
+ - Reference
+ - Web
+translation_of: Web/API/Document/createElement
+---
+<div>{{APIRef("DOM")}}</div>
+
+<p>HTML 문서에서, <strong><code>Document.createElement()</code></strong> 메서드는 지정한 <code>tagName</code>의 HTML 요소를 만들어 반환합니다. <code>tagName</code>을 인식할 수 없으면 {{domxref("HTMLUnknownElement")}}를 대신 반환합니다.</p>
+
+<h2 id=".EB.AC.B8.EB.B2.95" name=".EB.AC.B8.EB.B2.95">구문</h2>
+
+<pre class="eval"><var>let element</var> = <var>document</var>.createElement(<var>tagName[, options]</var>);</pre>
+
+<h3 id="매개변수">매개변수</h3>
+
+<dl>
+ <dt><code>tagName</code></dt>
+ <dd>생성할 요소의 유형을 가리키는 문자열.</dd>
+ <dt><code>options</code> {{optional_inline}}</dt>
+ <dd><code>is</code> 속성 하나를 가진 <code>ElementCreationOptions</code> 객체. 속성의 값은 <code>customElements.define()</code>을 사용해 정의한 사용자 정의 요소입니다.</dd>
+</dl>
+
+<h3 id="반환_값">반환 값</h3>
+
+<p>새로운 {{domxref("Element")}}.</p>
+
+<h2 id="예제" name="예제">예제</h2>
+
+<p>아래 예제는 새로운 <code>&lt;div&gt;</code> 엘리먼트를 생성한 후, ID가 "div1" 인 요소 이전에 추가합니다.</p>
+
+<h4 id="HTML">HTML</h4>
+
+<pre class="brush: html"><code>&lt;!DOCTYPE html&gt;
+&lt;html&gt;
+&lt;head&gt;
+ &lt;title&gt;||Working with elements||&lt;/title&gt;
+&lt;/head&gt;
+&lt;body&gt;
+ &lt;div id="div1"&gt;위의 텍스트는 동적으로 추가했습니다.&lt;/div&gt;
+&lt;/body&gt;
+&lt;/html&gt;</code></pre>
+
+<h4 id="JavaScript">JavaScript</h4>
+
+<pre class="brush: js"><code>document.body.onload = addElement;
+
+function addElement () {
+ // create a new div element
+ var newDiv = document.createElement("div");
+ // and give it some content
+ var newContent = document.createTextNode("환영합니다!");
+ // add the text node to the newly created div
+ newDiv.appendChild(newContent);
+
+ // add the newly created element and its content into the DOM
+ var currentDiv = document.getElementById("div1");
+ document.body.insertBefore(newDiv, currentDiv);
+}</code></pre>
+
+<p>{{EmbedLiveSample("예제", 500, 50)}}</p>
+
+<h2 id="명세">명세</h2>
+
+<table class="standard-table">
+ <thead>
+ <tr>
+ <th scope="col">Specification</th>
+ <th scope="col">Status</th>
+ <th scope="col">Comment</th>
+ </tr>
+ </thead>
+ <tbody>
+ <tr>
+ <td>{{SpecName('DOM WHATWG', "#dom-document-createelement", "Document.createElement")}}</td>
+ <td>{{Spec2('DOM WHATWG')}}</td>
+ <td> </td>
+ </tr>
+ </tbody>
+</table>
+
+<h2 id="브라우저_호환성">브라우저 호환성</h2>
+
+<p>{{Compat("api.Document.createElement")}}</p>
+
+<h2 id="같이_보기">같이 보기</h2>
+
+<ul>
+ <li>{{domxref("Node.removeChild()")}}</li>
+ <li>{{domxref("Node.replaceChild()")}}</li>
+ <li>{{domxref("Node.appendChild()")}}</li>
+ <li>{{domxref("Node.insertBefore()")}}</li>
+ <li>{{domxref("Node.hasChildNodes()")}}</li>
+ <li>{{domxref("document.createElementNS()")}} — to explicitly specify the namespace URI for the element.</li>
+</ul>