Read multi-line content in Firefox

Lets you read an element that is editable for content in Firefox

<span id="myinput" contenteditable="true">This is editable.<br>Yes it is.</span>

immediately after manually adding two white spaces at the end of the text.

I get:

  • textContent => "This is editable.Yes it is. "

  • innerText => undefined

  • innerHTML => "This is editable.<br>Yes it is. &nbsp;"

  • jQuery .text()=> same as textContent, i.e. line breaks are lost

How to get "This is editable.\n Yes it is. "? (Of course, some regex can work on innerHTML, but it's dirty: maybe there are a lot of things that I need to parse ...)

+3
source share

All Articles