語法
js
item(index)
引數
index-
一個整數。
返回值
一個 CSSRule。
示例
在下面的示例中,我們假設 myRules 列表僅有三個專案。
js
let myRules = document.styleSheets[0].cssRules;
console.log(myRules.item(0)); // Logs the first CSSRule item from this list
// Accessing non-existing items using this method will return null instead of undefined
console.log(myRules.item(5)); // null
console.log(myRules[5]); // undefined
規範
| 規範 |
|---|
| CSS 物件模型 (CSSOM) # dom-cssrulelist-item |
瀏覽器相容性
載入中…