LearnFast.Ninja

Make a div editable with JavaScript using content editable

Here an easy way to type text in a div onclick event. Use JavaScript event like on click to activate content editable to be true.

Step 1: Use JavaScript event like on click to activate content editable to be true. 

<html>

<head>

</head>

<body>

    <div onclick="this.contentEditable='true';"

            style="background: whiteSmoke; border: 1px solid #ccc; width: 200px; padding: 10px;">

        You can edit this divs text.

    </div>

</body>

</html>

 
Result:


Tags

javascript

div editable