CSSGroupingRule.deleteRule()

Baseline Widely available

This feature is well established and works across many devices and browser versions. It’s been available across browsers since September 2015.

deleteRule()CSSGroupingRule インターフェイスのメソッドで、子 CSS ルールの一覧からある CSS ルールを取り除きます。

構文

js
deleteRule(index);

引数

index

削除するルールの位置です。

返値

なし (undefined)。

例外

IndexSizeError DOMException

index が子 CSS ルールの数以上であった場合に発生します。

InvalidStateError DOMException

削除しようとしているルールが @namespace アットルールであり、子 CSS ルールに @import アットルールまたは @namespace アットルール以外の者があった場合に発生します。

js
let myRules = document.styleSheets[0].cssRules;
myRules[0].deleteRule(2); /* deletes the rule at index 2 */

仕様書

Specification
CSS Object Model (CSSOM)
# dom-cssgroupingrule-deleterule

ブラウザーの互換性

Report problems with this compatibility data on GitHub
desktopmobile
Chrome
Edge
Firefox
Opera
Safari
Chrome Android
Firefox for Android
Opera Android
Safari on iOS
Samsung Internet
WebView Android
WebView on iOS
deleteRule

Legend

Tip: you can click/tap on a cell for more information.

Full support
Full support