CSSRule.cssText
Baseline Widely available
This feature is well established and works across many devices and browser versions. It’s been available across browsers since September 2015.
概述
cssText 返回样式规则所包含的实际文本。想要能够动态的设置一个样式表规则,查看使用动态样式信息。
语法
string = cssRule.cssText
例子
html
<style>
body {
background-color: darkblue;
}
</style>
<script>
var stylesheet = document.styleSheets[0];
alert(stylesheet.cssRules[0].cssText); // body { background-color: darkblue; }
</script>