views:

369

answers:

2

I working on an intranet project for IE6 (i know...) and I need to output some HTML code from a div.

I use $('#output').text($('#container').html());

But IE6 outputs all the code in uppercase:

<TABLE border=1>
 <TR>
  <TD>Test Content</TD>
 </TR>
</TABLE>

How can I convert HTML tags to lowercase using jQuery?

Would be useful to have a plugin that could recursively go trough the DOM-tree.

A: 

What if you use .html() instead of .text()?

Alec
I assume the OP wants to display the HTML so it can be copy/pasted. If it was being treated as markup, it wouldn't matter that IE used upper case tag and attribute names internally.
David Dorward
yes, I should have made that clear.
mofle
Well, thanks for the down-votes.
Alec
+2  A: 

Try

$('#output').text($('#container').html().replace(/<\/?[A-Z]+.*?>/g, function (m) { return m.toLowerCase(); }));
BrunoLM
almost, doesn't support attributes though. can you fix that?
mofle
I changed it to support attributes, but it is also change attributes to lowercase, is that what you want?
BrunoLM
yes, thank you so much :D
mofle