<!DOCTYPE html> <html> <body> <h1>Element 对象</h1> <h2>removeAttributeNode() 方法</h2> <a id="myAnchor" href="https://www.sou-xun.com">链接:访问 sou-xun.com</a> <p id="demo">单击“移除”可从 a 元素中移除 href 属性节点。</p> <button onclick="myFunction()">移除</button> <script> function myFunction() { const element = document.getElementById("myAnchor"); const attr = element.getAttributeNode("href"); element.removeAttributeNode(attr); } </script> </body> </html>