JS - Remove a tag without deleting content

前端 未结 8 1082
渐次进展
渐次进展 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:35

    The weather is sure sunny today

    ; var span=document.getElementsByTagName('span')[0]; // get the span var pa=span.parentNode; while(span.firstChild) pa.insertBefore(span.firstChild, span); pa.removeChild(span);

提交回复
热议问题