Convert HTML tag to lowercase

2019-07-04 16:48发布

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.

2条回答
Anthone
2楼-- · 2019-07-04 17:24

Try

$('#output').text($('#container').html().replace(/<\/?[A-Z]+.*?>/g, function (m) { return m.toLowerCase(); }));
查看更多
Bombasti
3楼-- · 2019-07-04 17:44

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

查看更多
登录 后发表回答