好好学习!
<script type="text/javascript"> function replaceMessage(){ var newnode =document.createElement("i"); var oldnode =document.getElementById("oldnode"); var oldnodetext=oldnode.innerText; var newnodetext =document.createTextNode(oldnodetext); newnode.appendChild(newnodetext); for(const e of oldnode.attributes){ if(e.name=="id"){ newnode.setAttribute(e.name,"newnode"); continue; } newnode.setAttribute(e.name,e.value); } oldnode.parentNode.replaceChild(newnode,oldnode); } </script>