Consider such html piece:
<p>foo</p><p>bar</p>
If you run (for example) jQuery text
for it you will get "foobar" -- so it is raw text actually, not textual representation.
I am looking for some ready to use library to get textual representation, in this case it should be -- "foo\nbar". Or clever hints how to make this as easy as possible ;-).
NOTE: I am not looking for beautiful output text, but just preserved meaning of whitespaces, so for:
<tr><td>foo</td><td>bar</td></tr>
<tr><td>1</td><td>2</td></tr>
I will be happy with
foo bar
1 2
it does NOT have to be:
foo bar
1 2
(but of course no harm done).
Have you looked at the
innerText
ortextContent
properties?Example
Adds a PRE tag to the body and appends the body text.
Edit
Does using a range work with firefox?
Edit
It looks like you're stuck with a parsing function like this then.