How to unwrap text using jQuery?

前端 未结 5 1748
我寻月下人不归
我寻月下人不归 2020-12-08 11:18

How to unwrap a text from a HTML tag using jQUery?

For instance, how to transform this HTML

A sentence with bold

5条回答
  •  挽巷
    挽巷 (楼主)
    2020-12-08 11:45

    I think relying solely on jQuery in this case needlessly complicates things. It would be easier to use the replace method which accepts either a normal string or a regular expression.

    Using regex is generally the way to go in this case, because you want multiple substitutions which have roughly the same pattern.

提交回复
热议问题