沐沐3381925
2020-12-02 20:18
<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>
加油啊
JavaScript进阶篇
468195 学习 · 21891 问题
相似问题