HTMLElement: isContentEditable 属性
HTMLElement.isContentEditable 只读属性返回一个布尔值,如果该元素的内容是可编辑的,则返回 true;否则返回 false。
值
一个布尔值。
示例
HTML
html
<p id="firstParagraph">Uneditable Paragraph</p>
<p id="secondParagraph" contenteditable="true">Editable Paragraph</p>
<p id="infoText1">Is the first paragraph editable?</p>
<p id="infoText2">Is the second paragraph editable?</p>
JavaScript
js
const firstParagraph = document.getElementById("firstParagraph");
const secondParagraph = document.getElementById("secondParagraph");
const infoText1 = document.getElementById("infoText1");
const infoText2 = document.getElementById("infoText2");
infoText1.textContent += ` ${firstParagraph.isContentEditable}`;
infoText2.textContent += ` ${secondParagraph.isContentEditable}`;
结果
规范
| 规范 |
|---|
| HTML # dom-iscontenteditable-dev |
浏览器兼容性
加载中…