How to unwrap text using jQuery?

前端 未结 5 1753
我寻月下人不归
我寻月下人不归 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:58

    How you do it depends on the additional constraints in your situation.

    There's no general way to unbold.

    If the tags are always , then you can do this

    var h = $(elementSelector).html;
    h = h.replace("","");
    h = h.replace("","");
    $(elementSelector).html(h);
    

    I'm not sure why you don't like Regex.

提交回复
热议问题