CSSOM
The deleteRule() method of the
CSSGroupingRule interface removes a CSS rule from a list of child CSS
rules.
Syntax
deleteRule(index)
Parameters
index- : The index of the rule to delete.
Return value
None (undefined).
Exceptions
IndexSizeErrorDOMException- : Thrown if index is greater than or equal to the number of child CSS rules.
InvalidStateErrorDOMException- : Thrown if the rule being removed is an
@namespaceat-rule, and the list of child CSS rules contains anything other than@importat-rules and@namespaceat-rules.
- : Thrown if the rule being removed is an
Examples
let myRules = document.styleSheets[0].cssRules;
myRules[0].deleteRule(2); /* deletes the rule at index 2 */
Specifications
Browser compatibility
来源:MDN Web Docs / Mozilla 贡献者 · 作者与贡献记录 · CC BY-SA 2.5。离线整理了版式、链接和媒体显示。
