diff options
author | Peter Bengtsson <mail@peterbe.com> | 2020-12-08 14:42:17 -0500 |
---|---|---|
committer | Peter Bengtsson <mail@peterbe.com> | 2020-12-08 14:42:17 -0500 |
commit | da78a9e329e272dedb2400b79a3bdeebff387d47 (patch) | |
tree | e6ef8aa7c43556f55ddfe031a01cf0a8fa271bfe /files/ko/web/api/node/innertext/index.html | |
parent | 1109132f09d75da9a28b649c7677bb6ce07c40c0 (diff) | |
download | translated-content-da78a9e329e272dedb2400b79a3bdeebff387d47.tar.gz translated-content-da78a9e329e272dedb2400b79a3bdeebff387d47.tar.bz2 translated-content-da78a9e329e272dedb2400b79a3bdeebff387d47.zip |
initial commit
Diffstat (limited to 'files/ko/web/api/node/innertext/index.html')
-rw-r--r-- | files/ko/web/api/node/innertext/index.html | 88 |
1 files changed, 88 insertions, 0 deletions
diff --git a/files/ko/web/api/node/innertext/index.html b/files/ko/web/api/node/innertext/index.html new file mode 100644 index 0000000000..414fab5c00 --- /dev/null +++ b/files/ko/web/api/node/innertext/index.html @@ -0,0 +1,88 @@ +--- +title: Node.innerText +slug: Web/API/Node/innerText +tags: + - API + - DOM + - HTMLElement + - Property + - Reference +translation_of: Web/API/HTMLElement/innerText +--- +<div>{{APIRef("HTML DOM")}}</div> + +<p><span class="seoSummary">{{domxref("HTMLElement")}} 인터페이스의 <code><strong>innerText</strong></code> 속성은 요소와 그 자손의 렌더링 된 텍스트 콘텐츠를 나타냅니다.</span> <code>innerText</code>는 사용자가 커서를 이용해 요소의 콘텐츠를 선택하고 클립보드에 복사했을 때 얻을 수 있는 텍스트의 근삿값을 제공합니다.</p> + +<div class="blockIndicator note"> +<p><strong>참고:</strong> <code>innerText</code>는 {{domxref("Node.textContent")}}와 혼동하기 쉬우나 중요한 차이점을 가지고 있습니다. 기본적으로, <code>innerText</code>는 텍스트의 렌더링 후 모습을 인식할 수 있지만 <code>textContent</code>는 그렇지 않습니다.</p> +</div> + +<h2 id="구문">구문</h2> + +<pre>const renderedText = <em>htmlElement</em>.innerText +<em>htmlElement</em>.innerText = <em>string</em> +</pre> + +<h3 id="값">값</h3> + +<p>요소의 렌더링 된 텍스트 콘텐츠를 나타내는 {{domxref("DOMString")}}. 요소 자체가 <a href="https://html.spec.whatwg.org/multipage/rendering.html#being-rendered">렌더링 중</a>이 아니라면 {{domxref("Node.textContent")}} 속성의 값과 동일합니다.</p> + +<h2 id="예제">예제</h2> + +<p>다음 예제는 <code>innerText</code>와 {{domxref("Node.textContent")}}를 비교합니다. <code>innerText</code>가 {{htmlElement("br")}} 태그를 인식하고, 숨겨진 요소를 무시하는 점에 주목하세요.</p> + +<h3 id="HTML">HTML</h3> + +<pre class="brush: html"><h3>원본 요소:</h3> +<p id="source"> + <style>#source { color: red; }</style> +아래에서<br>이 글을<br>어떻게 인식하는지 살펴보세요. + <span style="display:none">숨겨진 글</span> +</p> +<h3>textContent 결과:</h3> +<textarea id="textContentOutput" rows="6" cols="30" readonly>...</textarea> +<h3>innerText 결과:</h3> +<textarea id="innerTextOutput" rows="6" cols="30" readonly>...</textarea></pre> + +<h3 id="JavaScript">JavaScript</h3> + +<pre class="brush: js">const source = document.getElementById('source'); +const textContentOutput = document.getElementById('textContentOutput'); +const innerTextOutput = document.getElementById('innerTextOutput'); + +textContentOutput.innerHTML = source.textContent; +innerTextOutput.innerHTML = source.innerText;</pre> + +<h3 id="결과">결과</h3> + +<p>{{EmbedLiveSample("예제", 700, 450)}}</p> + +<h2 id="명세">명세</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('HTML WHATWG', 'dom.html#the-innertext-idl-attribute', 'innerText')}}</td> + <td>{{Spec2('HTML WHATWG')}}</td> + <td>Introduced, based on the <a href="https://github.com/rocallahan/innerText-spec">draft of the innerText specification</a>. See <a href="https://github.com/whatwg/html/issues/465">whatwg/html#465</a> and <a href="https://github.com/whatwg/compat/issues/5">whatwg/compat#5</a> for history.</td> + </tr> + </tbody> +</table> + +<h2 id="Browser_Compatibility" name="Browser_Compatibility">브라우저 호환성</h2> + + + +<p>{{Compat("api.HTMLElement.innerText")}}</p> + +<h2 id="같이_보기">같이 보기</h2> + +<ul> + <li>{{domxref("HTMLElement.outerText")}}</li> + <li>{{domxref("Element.innerHTML")}}</li> +</ul> |