CSSStyleSheet: removeRule() method
MDN Web Docs · نسخهٔ df622a2a1c1e · CC BY-SA 2.5 و مجوز جداگانهٔ ناشر برای نمونهکد
{{APIRef("CSSOM")}}
The obsolete {{domxref("CSSStyleSheet")}} method **removeRule()** removes a rule from the stylesheet object. It is functionally identical to the standard, preferred method {{domxref("CSSStyleSheet.deleteRule", "deleteRule()")}}.
توجه: This is a _legacy method_ which has been replaced by the standard method {{domxref("CSSStyleSheet.deleteRule", "deleteRule()")}}. You should use that instead.
Syntax
js-nolint
removeRule(index)Parameters
index- : The index into the stylesheet's {{domxref("CSSRuleList")}} indicating the rule to be
removed.
Return value
None ({{jsxref("undefined")}}).
Examples
This example removes the first rule from the stylesheet myStyles.
js
myStyles.removeRule(0);You can rewrite this to use the standard deleteRule() method very easily:
js
myStyles.deleteRule(0);Specifications
{{Specifications}}
Browser compatibility
{{Compat}}
See also
- CSS Object Model
- Using dynamic styling information
- {{domxref("CSSStyleSheet.insertRule", "insertRule()")}}