我想知道是否可以删除标签,但是让内容保持屏幕状态?例如,是否可以删除SPAN标签,但将SPAN的内容留在那里?
- <p>The weather is sure <span>sunny</span> today</p> //original
- <p>The weather is sure sunny today</p> //turn it into this
我已经尝试使用this方法使用replaceWith(),但它将HTML转换为
- <p>
- "The weather is sure "
- "sunny"
- " today"
- </p>
编辑:测试了所有答案后,我意识到我的代码是错误的.我继续获得三个拆分文本节点的原因是由于插入了SPAN标签.我将创建另一个问题来尝试解决我的问题.