【发布时间】:2014-01-31 14:10:52
【问题描述】:
我知道如何使用 replace 和 replaceWith,但我需要做一些不同的事情。
示例字符串:
<span class="highlight_grey">example:</span> some additional text
& <span class="highlight_grey">again...</span> and to wrap up some
regular <span>span.. no class here</span>
想要的结果:
[highlight color="default"]example:[/highlight] some additional text
& [highlight color="default"]again...[/highlight] and to wrap up some
regular <span>span.. no class here</span>
element.replace 在这里不起作用,因为我需要替换整个换行并保留文本。replaceWith 也对我没有帮助,因为我需要使用字符串并且我再次替换
包装元素。
感谢您的帮助
【问题讨论】:
标签: jquery replace innerhtml replacewith