日期:2014-05-16 浏览次数:20670 次
<div id="test"><i>T</i>his is <u>something</u>. </div>
<div id="test">
<i>T</i>h<span class="bold">i<span class="red">s</span></span>
<span class="bold">i<span class="blue">s</span></span>
<u>something</u>.
</div>
<h1>by theforever@csdn.net</h1>
<div id="test"><i>T</i>his is <u>something</u>. </div>
<script>
var theforever_csdn=document.getElementById('test');
var theforever_csdn_Html=theforever_csdn.innerHTML;
theforever_csdn_Html=theforever_csdn_Html.replace(new RegExp('is','gm'),'<SPAN CLASS="bold">is</SPAN>');
theforever_csdn_Html=theforever_csdn_Html.replace(new RegExp('s','m'),'<SPAN CLASS="red">s</SPAN>');
theforever_csdn.innerHTML=theforever_csdn_Html.replace(new RegExp('([^>])s','m'),'$1<SPAN CLASS="blue">s</SPAN>');
alert(theforever_csdn.innerHTML);
</script>