aboutsummaryrefslogtreecommitdiff
path: root/files/zh-tw/web/api/htmlelement/innertext/index.html
blob: fe76e053a4bc95c2029c4451c209ab51f5dc4ac7 (plain)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
---
title: Node.innerText
slug: Web/API/HTMLElement/innerText
translation_of: Web/API/HTMLElement/innerText
original_slug: Web/API/Node/innerText
---
<div>{{APIRef("DOM")}}</div>

<h2 id="概述">概述</h2>

<p><code><strong>Node.innerText</strong></code> 是一個代表節點及其後代之「已渲染」(rendered)文字內容的屬性。如同一個存取器,<code>Node.innerText</code> 近似於使用者利用游標選取成高亮後複製至剪貼簿之元素的內容。此功能最初由 Internet Explorer 提供,並在被所有主要瀏覽器採納之後,於 2016 年正式成為 HTML 標準。</p>

<p>{{domxref("Node.textContent")}} 屬性是一個相似的選擇,但兩者之間仍有非常不同的差異。</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>

{{Compat("api.HTMLElement.innerText")}}

<h2 id="參見">參見</h2>

<ul>
 <li>{{domxref("HTMLElement.outerText")}}</li>
 <li>{{domxref("Element.innerHTML")}}</li>
</ul>