Convert HTML tag to lowercase

夙愿已清 提交于 2019-12-10 19:12:14

问题


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.


回答1:


Try

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



回答2:


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



来源:https://stackoverflow.com/questions/2873326/convert-html-tag-to-lowercase

易学教程内所有资源均来自网络或用户发布的内容,如有违反法律规定的内容欢迎反馈
该文章没有解决你所遇到的问题?点击提问,说说你的问题,让更多的人一起探讨吧!