1
我不得不更换所有一个div一些字符,但是当我运行的代码,该函数替换我也HTML标记字符JQuery的替换所有内容在一个div除了标签
我的代码是:
$("#main").children().each(function() {
$(this).html($(this).html().replace(/s/g, "K"));
})
<div id="main">
<p>Some contents that will be replaced... <span>this will not be in a span tag :(</span></p>
</div>
结果:
<div id="main">
<p>Kome contentK that will be replaced... <Kpan>this will not be in a Kpan tag :(</Kpan></p>
</div>