html - Edit contenteditable text with Ctrl-A (Select All) removing all child elements -
in div contenteditable="true", if select text using ctrl-a , type something, removing child elements within div, not text.
for example:
<div id="texteditor" contenteditable="true"> ctrl-a , edit me. <div id="topleft-ornament" class="ornament"></div> <div id="topright-ornament" class="ornament"></div> <div id="bottomleft-ornament" class="ornament"></div> <div id="bottomright-ornament" class="ornament"></div> </div>
the fiddle: http://jsfiddle.net/7jv4f/1/
the red circles (child elements of contenteditable div) in example above removed if text edited using ctrl-a.
any idea how prevent it?
thx :d
so wrap text inside div , assign contenteditable
attribute particular element
<div contenteditable="true">ctrl-a , edit me.</div> <!-- wrap text, don't use contenteditable parent element -->
Comments
Post a Comment