CSSRuleList.item()
item() は CSSRuleList インターフェイスのメソッドで、 index で指定された CSSRule オブジェクトを返します。指定された index が存在しなければ null を返します。
構文
js
CSSRuleList.item(index);
引数
index-
整数です。
返値
CSSRule です。
例
以下の例では、 myRules という名前の CSSRuleList の最初のアイテムをコンソールに出力します。
js
let myRules = document.styleSheets[0].cssRules;
console.log(myRules[0]);
仕様書
| Specification |
|---|
| CSS Object Model (CSSOM) # dom-cssrulelist-item |
ブラウザーの互換性
BCD tables only load in the browser