Set element contentEditable property to true - Javascript DOM

Javascript examples for DOM:Element contentEditable

Description

Set element contentEditable property to true

Demo Code

ResultView the demo in separate window

<html>
   <head></head>
   <body> 
      <div id="myP">
         This is a paragraph. Click the button to make me editable.
      </div> 
      <button onclick="myFunction()">Try it</button> 
      <p id="demo"></p> 
      <script>
    function myFunction() {/* ww  w.  j a  v a2s  .c  om*/
        document.getElementById("myP").contentEditable = true;
        document.getElementById("demo").innerHTML = "The p element above is now editable. Try to change its text.";
    }
    
      </script>  
   </body>
</html>

Related Tutorials