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 |
瀏覽器相容性
載入中…