Sindre Sorhus
Sindre Sorhus

Reputation: 63477

Convert HTML tag to lowercase

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.

Upvotes: 5

Views: 4881

Answers (2)

BrunoLM
BrunoLM

Reputation: 100381

Try

$('#output').text($('#container').html().replace(/<\/?[A-Z]+.*?>/g, function (m) { return m.toLowerCase(); }));

Upvotes: 7

Alec
Alec

Reputation: 9078

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

Upvotes: -2

Related Questions