HTMLElement.isContentEditable

Baseline Widely available

This feature is well established and works across many devices and browser versions. It’s been available across browsers since December 2021.

La propriété en lecture seule HTMLElement.isContentEditable renvoie un booléen qui est true (vrai) si le contenu de l'élément est éditable ; sinon elle renvoie false (faux).

Syntaxe

js
editable = element.isContentEditable;

Exemple

JavaScript

js
document.getElementById("infoText1").innerHTML +=
  document.getElementById("myText1").isContentEditable;
document.getElementById("infoText2").innerHTML +=
  document.getElementById("myText2").isContentEditable;

HTML

html
<p id="myText1">Uneditable Paragraph</p>
<p id="myText2" contenteditable="true">Editable Paragraph</p>

<p id="infoText1">Can edit the first paragraph?</p>
<p id="infoText2">Can edit the second paragraph?</p>

Résultat

Spécifications

Specification
HTML Standard
# dom-iscontenteditable-dev

Compatibilité des navigateurs

BCD tables only load in the browser

Voir aussi