运行 ❯
获取您的
自有
网站
×
更改方向
保存代码
更改主题,深色/浅色
前往 Spaces
<!DOCTYPE html> <html> <head> <style> #ex1 { color: red; } </style> </head> <body> <h1>The setProperty() Method</h1> <p>Click the button to set a new CSS property with "important" priority.</p> <button onclick="myFunction()">Try it</button> <div id="ex1">Some text.</div> <script> function myFunction() { var declaration = document.styleSheets[0].cssRules[0].style; var setprop = declaration.setProperty("background-color", "yellow", "important"); } </script> </body> </html>