How do I copy <div contentEditable="true">
to <textarea>
without stripping out all the HTML source codes?
I want automatically copy all source codes written in an editable div without stripping them out when they are copied to the textarea.
<script language="javascript" type="text/javascript">
function copyText() {
var output = document.getElementById("divtext").innerHTML;
document.getElementById("text").value = output;
}
</script>
<div id="divtext" contentEditable="true" onkeyup="copyText();" style="text-align:left; width: 499px; height: 230px;"></div>
<textarea name="text" id="text" rows="14" cols="54" wrap="soft"></textarea>
The codes work, they do copy from div to textarea, but they strip them out so what I think is needed is a way to replace the stripped out so to keep or preserve the text as it was written without having it stripped out.
How do I add that replace function?
it will force a line break. – Neil Mar 14 '17 at 03:01