Remove tag around a text node using javascript

前端 未结 8 1943
夕颜
夕颜 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条回答
  •  被撕碎了的回忆
    2021-02-06 15:04

    A better unwrap plugin:

    $.fn.unwrap = function() {
      this.parent(':not(body)')
        .each(function(){
          $(this).replaceWith( this.childNodes );
        });
    
      return this;
    };
    

    from Ben Alman

提交回复
热议问题