HTMLElement: thuộc tính isContentEditable
Baseline
Widely available
This feature is well established and works across many devices and browser versions. It’s been available across browsers since July 2015.
Thuộc tính chỉ đọc HTMLElement.isContentEditable trả về giá trị boolean là true nếu nội dung của phần tử có thể chỉnh sửa; ngược lại trả về false.
Giá trị
Một giá trị boolean.
Ví dụ
>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}`;
Kết quả
Thông số kỹ thuật
| Specification |
|---|
| HTML> # dom-iscontenteditable-dev> |
Tương thích trình duyệt
Xem thêm
HTMLElement/contentEditable- Thuộc tính toàn cục
contenteditable.