The CSSStyleSheet.deleteRule()
method removes a style rule from the current style sheet object.
stylesheet.deleteRule(index)
index
is a long number representing the position of the rule.Void.
myStyles.deleteRule(0);
The below polyfill will bring support to IE5-IE8.
if (!CSSStyleSheet.prototype.deleteRule) CSSStyleSheet.prototype.deleteRule = CSSStyleSheet.prototype.removeRule;
Specification | Status | Comment |
---|---|---|
CSS Object Model (CSSOM) The definition of 'CSSStyleSheet.deleteRule()' in that specification. | Working Draft | |
Document Object Model (DOM) Level 2 Style Specification The definition of 'CSSStyleSheet.deleteRule()' in that specification. | Obsolete | Initial definition |
Desktop | ||||||
---|---|---|---|---|---|---|
Chrome | Edge | Firefox | Internet Explorer | Opera | Safari | |
Basic support | Yes | Yes | Yes | 9 | Yes | Yes |
Mobile | |||||||
---|---|---|---|---|---|---|---|
Android webview | Chrome for Android | Edge Mobile | Firefox for Android | Opera for Android | iOS Safari | Samsung Internet | |
Basic support | Yes | Yes | Yes | Yes | Yes | Yes | ? |
removeRule(); // remove first rule
addRule()
and .rules
instead of insertRule()
and .cssRules
respectively.
© 2005–2018 Mozilla Developer Network and individual contributors.
Licensed under the Creative Commons Attribution-ShareAlike License v2.5 or later.
https://developer.mozilla.org/en-US/docs/Web/API/CSSStyleSheet/deleteRule