How to replace the current node

使用 ChildNode.replaceWith();

var span = document.createElement('span');
el.replaceWith(span);

 

note: 

1 must have a parent node of the current node;

2. Alternatively parameter node can be an element node, a text node may be;

Guess you like

Origin www.cnblogs.com/aisowe/p/11530928.html