Remove tag around a text node using javascript

前端 未结 8 2060
夕颜
夕颜 2021-02-06 14:12

If I have some HTML that looks like this:

This is some text that is being written with a high
8条回答
  •  猫巷女王i
    2021-02-06 15:06

    This will do what you want, and also preserve any tags within the .highlight span.

    content = $(".highlight").contents();
    $(".highlight").replaceWith(content);
    

提交回复
热议问题