views:

59

answers:

1

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?

A: 

Try this:

var contents = $(div#Test).clone();
returnvoid
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