HTMLElement : propriété isContentEditable
Baseline
Widely available
Cette fonctionnalité est bien établie et fonctionne sur de nombreux appareils et versions de navigateurs. Elle est disponible sur tous les navigateurs depuis juillet 2015.
La propriété en lecture seule isContentEditable de l'interface HTMLElement retourne un booléen qui est true (vrai) si le contenu de l'élément est éditable ; sinon elle retourne false (faux).
Valeur
Une valeur booléenne.
Exemples
>HTML
html
<p id="firstParagraph">Paragraphe non éditable</p>
<p id="secondParagraph" contenteditable="true">Paragraphe éditable</p>
<p id="infoText1">Le premier paragraphe est-il éditable ?</p>
<p id="infoText2">Le second paragraphe est-il éditable ?</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}`;
Résultat
Spécifications
| Specification |
|---|
| HTML> # dom-iscontenteditable-dev> |
Compatibilité des navigateurs
Voir aussi
- La propriété
HTMLElement.contentEditable - L'attribut HTML universel
contenteditable.