2

Suppose I have the following HTML on the page:

<div id="Test">
One
Two
</div>

and this jQuery:

var contents=$("div#Test").html()

In Chrome and Firefox, the resulting string contents includes line breaks - that is, between "One" and "Two" there's character code 10. In IE, though, it seems to collapse any white space and line feeds to a single space (character code 32).

I want to take contents and pass it to a Markdown engine, so I need the whitespace and linefeeds to come through as is. How can I do this?

Herb Caudill
  • 50,043
  • 39
  • 124
  • 173

1 Answers1

-1

Try this:

var contents = $(div#Test).clone();
Herb Caudill
  • 50,043
  • 39
  • 124
  • 173
returnvoid
  • 434
  • 1
  • 7
  • 19
  • That returns a jQuery object containing a clone of div#Test - not helpful at all. I need the text contents of div#Test. – Herb Caudill Jan 15 '10 at 18:45