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 |
浏览器兼容性
BCD 表格仅在启用 JavaScript 的浏览器中加载。