CSSRule.cssText - Web APIs 编辑
The cssText
property of the CSSRule
interface returns the actual text of a CSSStyleSheet
style-rule.
Note: Do not confuse this property with element-style CSSStyleDeclaration.cssText
.
Be aware that this property can no longer be set directly, as it is now specified to be functionally modify-only, and silently so. In other words, attempting to set it does absolutely nothing, and doesn't even omit a warning or error. Furthermore, it has no settable sub-properties. Therefore, to modify it, use the stylesheet's cssRules
[index]
properties .selectorText
and .style
(or its sub-properties). See Using dynamic styling information for details.
Syntax
string = cssRule.cssText
Example
<style>
body {
background-color: darkblue;
}
</style>
<script>
var stylesheet = document.styleSheets[0];
alert(stylesheet.cssRules[0].cssText); // body { background-color: darkblue; }
</script>
Specifications
Specification | Status | Comment |
---|---|---|
CSS Object Model (CSSOM) The definition of 'CSSRule: cssText' in that specification. | Working Draft |
Browser compatibility
BCD tables only load in the browser
如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。
绑定邮箱获取回复消息
由于您还没有绑定你的真实邮箱,如果其他用户或者作者回复了您的评论,将不能在第一时间通知您!
发布评论