How to make an HTML <div> element editable cross-browser?
59,644
Solution 1
I found out how.
You use the contentEditable property of the DOMElement, like so
<div onClick="this.contentEditable='true';">
lorem ipsum dolor lorem ipsum dolorlorem ipsum dolor
</div>
Solution 2
You can do this in pure HTML
<div class="editable" contenteditable="true">
Editable text...
</div>
Hope this helps!
Solution 3
Set contentEditable
property of the element to "true"
:
element.contentEditable = "true";
See also:
Author by
Cristian Toma
Interested in .NET, PHP and JavaScript programming. I'm very passionate about writing beautiful code against well set design patterns and standards.
Updated on July 08, 2022Comments
-
Cristian Toma almost 2 years
Do you know how to make a
<div>
editable with JavaScript? I'm looking for cross-browser solution.Something similar to a rich text area, but that uses an editable
<iframe>
. I need something similar for a<div>
.
I don't want to use a replacement textbox.