HTML | DOM isContentEditable Property

The DOM isContentEditable property is used to return a boolean where true means the content of an element is editable and false represents content is not editable. This property is read-only.

Syntax:

Object.isContentEditable

Return Value: This property returns a boolean value.



  • true means that the content of an element is editable.
  • false means that the content of an element is not editable.

Example:

filter_none

edit
close

play_arrow

link
brightness_4
code

<!DOCTYPE html>
<html>
  
<head>
    <title>
      DOM iscontentEditable Property
  </title>
</head>
  
<body style="text-align: center">
    <h1 style="color:green">
            GeeksforGeeks
        </h1>
  
    <h2>
            DOM iscontentEditable Property
        </h2>
    <span id="P" contenteditable="true">
      Span 1 is editable.
          
    </span>
    <span id="P1">
      Span 2 is non editable.
    </span>
    <br>
    <br>
    <button onclick="myFunction()">
      Click me!
    </button>
  
    <p id="d"></p>
    <p id="d1"></p>
  
    <script>
        function myFunction() {
            var x =
                document.getElementById("P").isContentEditable;
            var y =
                document.getElementById("P1").isContentEditable;
            document.getElementById("d").innerHTML =
                "Span 1 is editable: " + x;
            document.getElementById("d1").innerHTML =
                "Span 2 is editable: " + y;
        }
    </script>
</body>
  
</html>

chevron_right


Output:
Before clicking the button:
isContentEditable
After clicking the button:
isContentEditable

Supported Browsers: The browser supported by isContentEditable property are listed below:

  • Google Chrome 11.0
  • Internet Explorer 5.5
  • Firefox 3.0
  • Opera 10.6
  • Safari 3.2


My Personal Notes arrow_drop_up


If you like GeeksforGeeks and would like to contribute, you can also write an article using contribute.geeksforgeeks.org or mail your article to contribute@geeksforgeeks.org. See your article appearing on the GeeksforGeeks main page and help other Geeks.

Please Improve this article if you find anything incorrect by clicking on the "Improve Article" button below.




Article Tags :
Practice Tags :


Be the First to upvote.


Please write to us at contribute@geeksforgeeks.org to report any issue with the above content.