CSSGroupingRule: deleteRule() method
MDN Web Docs · نسخهٔ df622a2a1c1e · CC BY-SA 2.5 و مجوز جداگانهٔ ناشر برای نمونهکد
{{ APIRef("CSSOM") }}
The **deleteRule()** method of the {{domxref("CSSGroupingRule")}} interface removes a CSS rule from a list of child CSS rules.
Syntax
js-nolint
deleteRule(index)Parameters
index- : The index of the rule to delete.
Return value
None ({{jsxref("undefined")}}).
Exceptions
IndexSizeError{{domxref("DOMException")}}- : Thrown if _index_ is greater than or equal to the number of child CSS
rules.
InvalidStateError{{domxref("DOMException")}}- : 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.
Examples
js
let myRules = document.styleSheets[0].cssRules;
myRules[0].deleteRule(2); /* deletes the rule at index 2 */Specifications
{{Specifications}}
Browser compatibility
{{Compat}}