> The problem for me is that using text() in IE 6/7 doesn't preserve
> whitespace...

As a workaround, you can use an expression like this:

var pre = $("<pre>").get(0);

alert(pre.innerText || pre.textContent);

All the browsers seem to support one property or the other--or both.
Their text output isn't exactly the same in all cases, but at least
there's some sort of whitespace.

The additional case that jQuery's .text() has to handle is XML, where
neither of these properties are available. I guess that's why it
wasn't used.

I opened a ticket:
http://dev.jquery.com/ticket/3144

Reply via email to