运行 ❯
获取您的
自己的
网站
×
更改方向
保存代码
更改主题,深色/浅色
前往 Spaces
<!DOCTYPE html> <html> <head> <style> h1 { color: red; font-size: 50px; } </style> <script> function myFunction() { var s = document.styleSheets[0].rules[0].style; var ruleObj = s.parentRule; document.getElementById("demo").innerHTML = ruleObj.cssText; } </script> </head> <body> <h1>The parentRule Property</h1> <p>The parentRule property returns a CSSRule Object that represent the CSS rule for the specified style declaration.</p> <button onclick="myFunction()">Display the CSS Rule</button> <p id="demo"></p> </body> </html>