Javascript Reference - HTML DOM isContentEditable Property








The isContentEditable property returns whether the content of an element is editable or not.

This property is read-only.

Browser Support

isContentEditable Yes Yes Yes Yes Yes

Syntax

HTMLElementObject.isContentEditable 

Return Value

A Boolean type, returns true if the content of an element is editable, otherwise it returns false.





Example

The following code shows how to check if a <p> element is editable.


<!DOCTYPE html>
<html>
<body>
<p id="myP" contenteditable="true">editable</p>
<button onclick="myFunction()">test</button>
<script>
function myFunction() {<!--from www  .ja va 2 s  .  c  om-->
    var x = document.getElementById("myP").isContentEditable;
    console.log(x);
}
</script>

</body>
</html>

The code above is rendered as follows: