aboutsummaryrefslogtreecommitdiff
path: root/files/zh-cn/web/api/htmlelement/contenteditable/index.html
blob: d7e96660e8404c7805866d328bcd146d3496345a (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
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
---
title: HTMLElement.contentEditable
slug: Web/API/HTMLElement/contentEditable
translation_of: Web/API/HTMLElement/contentEditable
---
<div>
<div>
<div>{{ APIRef("HTML DOM") }}</div>
</div>
</div>

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

<p><strong><code>HTMLElement.contentEditable</code></strong> 属性用于表明元素是否是可编辑的。该枚举属性(enumerated attribute)可以具有下面的几种值之一:</p>

<ul>
 <li><code>"true"</code> 表明该元素可编辑。</li>
 <li><code>"false"</code> 表明该元素不可编辑。</li>
 <li><code>"inherit"</code> 表明该元素继承了其父元素的可编辑状态。</li>
</ul>

<h2 id="Syntax" name="Syntax">语法</h2>

<pre class="syntaxbox"><em>editable</em> = element.contentEditable
element.contentEditable = "true"
</pre>

<h2 id="Notes" name="Notes">规范</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('HTML WHATWG', 'interaction.html#contenteditable', 'contenteditable')}}</td>
   <td>{{Spec2('HTML WHATWG')}}</td>
   <td> <br>
     </td>
  </tr>
 </tbody>
</table>

<h2 id="浏览器兼容性">浏览器兼容性</h2>

<div>
<p>{{Compat("api.HTMLElement.contentEditable")}}</p>

<p>在 IE 浏览器中,<code>contenteditable</code> 不能直接用在 {{htmlelement("table")}}、 {{htmlelement("col")}}、 {{htmlelement("colgroup")}}、 {{htmlelement("tbody")}}、 {{htmlelement("td")}}、 {{htmlelement("tfoot")}}、 {{htmlelement("th")}}、 {{htmlelement("thead")}} 和 {{htmlelement("tr")}} 标签上。一个可编辑的 {{htmlelement("span")}} 或者 {{htmlelement("div")}} 标签可以放在表格单元格内部。</p>
</div>

<h2 id="相关链接">相关链接</h2>

<ul>
 <li>{{domxref("HTMLElement.isContentEditable")}}</li>
 <li>全局属性 <a href="https://developer.mozilla.org/zh-CN/docs/Web/HTML/Global_attributes/contenteditable">contenteditable</a></li>
 <li><a href="https://medium.com/medium-eng/why-contenteditable-is-terrible-122d8a40e480">Why ContentEditable is Terrible, Or: How the Medium Editor Works</a></li>
</ul>