Does this work?

alert($("<div>foo\nbar</div>").text());

(I'm in no mood to boot Windows just now, sorry ;-)

On Fri, Mar 6, 2009 at 8:02 AM, Martijn Houtman
<martijn.hout...@gmail.com> wrote:
>
> On Mar 6, 12:20 pm, "martijn.hout...@gmail.com"
> <martijn.hout...@gmail.com> wrote:
>> Just wanted to document this bug/feature in IE7:
>>
>> alert($("<div>foo\nbar</div>").html());
>>
>> This gives "foo bar" in IE7 and "foo\nbar" in FF. It might be related
>> tohttp://groups.google.com/group/jquery-en/browse_thread/thread/6f03f58...
>>
>> I suspect this is done by IE's DOM parser? And there is nothing to do
>> about it?
>
> Alright, so even though \n is not really an HTML character and it is
> not really supposed to be there, in my application I somewhat need it,
> so I really need a fix for this.
>
> Luckily, IE7 does not remove whitespace if you wrap it with a
> <textarea> element, so:
>
> alert($("<textarea>foo\nbar</textarea>").html());
>
> actually produces the correct behavior. Thanks to Yereth for the
> hint :-)
> --
> Martijn.

Reply via email to