English | 简体中文 | 繁體中文 | Русский язык | Français | Español | Português | Deutsch | 日本語 | 한국어 | Italiano | بالعربية

HTML DOM contentEditable Attribute

HTML DOM Element Object

AttributeAttribute to set or return whether the element's content is editable.

You can also useisContentEditableAttribute to determine whether the element's content is editable.

Syntax:

Return the contentEditable attribute:

HTMLElement.contentEditable

Set the contentEditable attribute:

HTMLElement.contentEditable = true|false
document.getElementById("x").contentEditable = "true";
")[0].contentEditable;/Test and See‹

Browser Compatibility

表中的数字指定了完全支持contentEditable属性的第一个浏览器版本:

The numbers in the table specify the first browser version that fully supports the contentEditable attribute:
Attribute113contentEditable593contentEditable26

.

Attribute ValueValue
Descriptiontrue|false
Indicates whether the element is editable.
  • Possible Values: -"true"

  • Represents that the element is editable -"false"

  • Represents that the element cannot be edited -"inherit"

Indicates whether the element inherits its parent's editable state

Technical DetailsReturn Value:

A String, if the element is editable, it will return true; otherwise, it returns false

More Examples3Check the first <h

Example3var x = document.getElementsByTagName("h"
")[0].contentEditable;/Test and See‹

Related ReferencesHTML DOM isContentEditable Reference:

HTML Reference:HTML contenteditable attribute

HTML DOM Element Object