You are here: Reference > JavaScript > client-side > HTML DOM > properties > isContentEditable

isContentEditable property

Browser support:
Returns a Boolean value that indicates whether the contents of the object are editable by the user.
The editable status of the element can be changed by the contentEditable and designMode properties.

Syntax:

object.isContentEditable;
You can find the related objects in the Supported by objects section below.
This property is read-only.

Possible values:

Boolean that indicates the editing privileges.
One of the following values:
false
Contents cannot be edited.
true
Contents are editable.
Default: this property has no default value.

Example HTML code 1:

This example illustrates the use of the isContentEditable property:
<head>
    <script type="text/javascript">
        function ToggleEditable (button) {
            var div = document.getElementById ("myDiv");

            if (div.isContentEditable) {
                div.contentEditable = "false";
                button.innerHTML = "Allow editing!";
            }
            else {
                div.contentEditable = "true";
                button.innerHTML = "Prevent editing!";
            }
        }
    </script>
</head>
<body>
    <div id="myDiv" contenteditable="true">Edit this text!</div>
    <br />
    <button onclick="ToggleEditable (this);">Prevent editing!</button>
</body>
Did you find this example helpful? yes no

Supported by objects:

Related pages:

External links:

User Contributed Comments

Post Content

Post Content