过时
This feature is obsolete. Although it may still work in some browsers, its use is discouraged since it could be removed at any time. Try to avoid using it.

过时 CSSStyleSheet 方法 removeRule() removes a rule from the stylesheet object. It is functionally identical to the standard, preferred method deleteRule() .

注意: 这是 legacy method which has been replaced by the standard method deleteRule() . You should use that instead.

句法

cssStyleSheet.removeRule(index)
					

参数

index
The index into the stylesheet's CSSRuleList indicating the rule to be removed.

返回值

undefined

范例

This example removes the first rule from the stylesheet myStyles .

 myStyles.removeRule(0);
					

You can rewrite this to use the standard deleteRule() method very easily:

myStyles.deleteRule(0);
					

规范

规范 状态 注释
CSS Object Model (CSSOM)
The definition of 'CSSStyleSheet.removeRule()' in that specification.
工作草案

浏览器兼容性

The compatibility table on this page is generated from structured data. If you'd like to contribute to the data, please check out https://github.com/mdn/browser-compat-data and send us a pull request. 更新 GitHub 上的兼容性数据
桌面 移动
Chrome Edge Firefox Internet Explorer Opera Safari Android webview Chrome for Android Firefox for Android Opera for Android Safari on iOS Samsung Internet
removeRule() 弃用 Chrome Yes Edge 12 Firefox 68 IE 9 Opera Yes Safari Yes WebView Android Yes Chrome Android Yes Firefox Android 68 Opera Android Yes Safari iOS Yes Samsung Internet Android Yes

图例

完整支持

完整支持

弃用。不要用于新网站。

弃用。不要用于新网站。

另请参阅

元数据

  • 最后修改: