I am trying to get the formatted text from a contenteditable='true' div to send to my server.
I used to use a textarea and when you get the value of a textarea it preserves white space and line breaks, but when using a contenteditable div even when using styles such as the following I can not get the properly formatted text:
white-space: pre-wrap;
word-wrap: break-word;
For example if I type this into my div:
"a
aa
asdf"
I will get this out with textContent:
"a aaasdf"
Is there any way to get formatted text out of a contenteditable div like a textarea?
` will be a problem. OP wants the `formatted` text. – Rahul Desai Dec 16 '14 at 11:53