使用正则表达式有很多困难。
这就是我想做的......
text<div> text </div><div> text </div><div> text </div>
把它变成
text<br> text<br>text<br>text
我尝试过做...
newhtml = newhtml.replace(/\<div>/g,'<br>');
newhtml = newhtml.replace(/\</div>/g,' ');
但这给出了错误的输出。 jquery 是否提供了更好的方法来做到这一点?
那是因为你转义了错误的东西,因为只有反斜杠需要转义。
newhtml = newhtml.replace(/<div>/g,'<br>');
newhtml = newhtml.replace(/<\/div>/g,' ');
本文内容由网友自发贡献,版权归原作者所有,本站不承担相应法律责任。如您发现有涉嫌抄袭侵权的内容,请联系:hwhale#tublm.com(使用前将#替换为@)