The deleteRule()
method of the CSSGroupingRule
interface removes a CSS rule from a list of child CSS rules.
The deleteRule()
method of the CSSGroupingRule
interface removes a CSS rule from a list of child CSS rules.
js
deleteRule(index)
index
The index of the rule to delete.
None (undefined
).
IndexSizeError
DOMException
Thrown if index is greater than or equal to the number of child CSS rules.
InvalidStateError
DOMException
Thrown if the rule being removed is an @namespace
at-rule, and the list of child CSS rules contains anything other than @import
at-rules and @namespace
at-rules.
js
let myRules = document.styleSheets[0].cssRules; myRules[0].deleteRule(2); /* deletes the rule at index 2 */
Desktop | Mobile | |||||||||||
---|---|---|---|---|---|---|---|---|---|---|---|---|
Chrome | Edge | Firefox | Internet Explorer | Opera | Safari | WebView Android | Chrome Android | Firefox for Android | Opera Android | Safari on IOS | Samsung Internet | |
deleteRule |
45 | 12 | 20 | No | 32 | 3 | 45 | 45 | 20 | 32 | 2 | 5.0 |
© 2005–2023 MDN contributors.
Licensed under the Creative Commons Attribution-ShareAlike License v2.5 or later.
https://developer.mozilla.org/en-US/docs/Web/API/CSSGroupingRule/deleteRule