<!DOCTYPE html> <html> <style> .democlass { color: red; } </style> <body> <h1 class="democlass">Element 对象</h1> <h2>removeAttributeNode() 方法</h2> <p>单击“删除”可从第一个 h1 元素中删除 class 属性节点。</p> <button onclick="myFunction()">class</button> <script> function myFunction() { const element = document.getElementsByTagName("H1")[0]; const attr = element.getAttributeNode("class"); element.removeAttributeNode(attr); } </script> </body> </html>