JS - Remove a tag without deleting content

前端 未结 8 1083
渐次进展
渐次进展 2021-01-04 04:09

I am wondering if it is possible to remove a tag but leave the content in tact? For example, is it possible to remove the SPAN tag but leave SPAN\'s content there?



        
8条回答
  •  生来不讨喜
    2021-01-04 04:43

    jQuery has easier ways:

    var spans = $('span');
    spans.contents().unwrap();
    

    With different selector methods, it is possible to remove deeply nested spans or just direct children spans of an element.

提交回复
热议问题