<!DOCTYPE html> <html> <head> <style> .democlass { color: red; } </style> </head> <body> <h1 class="democlass">Hello World</h1> <p id="demo">单击按钮从 h1 元素中删除 class 属性。</p> <button onclick="myFunction()">试一试</button> <script> function myFunction() { document.getElementsByTagName("H1")[0].removeAttribute("class"); } </script> </body> </html>