Name
CSSRuleList — an array of CSSRule objects
Availability
DOM Level 2 CSS
Properties
-
readonly unsigned long length
The number of CSSRule objects in this CSSRuleList array.
Methods
-
item( )
Returns the CSSRule object at the specified position. Instead of explicitly calling this method, JavaScript allows you to simply treat the CSSRuleList object as an array and to index it using standard square-bracket array notation. If the specified index is too large, this method returns
null
.
Description
This interface defines a read-only ordered list (i.e., an array) of
CSSRule objects. The length
property specifies the
number of rules in the list, and the item( )
method allows you to retrieve the rule at a specified position. In
JavaScript, CSSRuleList objects behave like JavaScript arrays, and
you can query an element from the list using square-bracket array
notation instead of calling the item( )
method.
(Note, however, that you cannot assign new nodes into a CSSRuleList
using square brackets.)
See Also
Type of
CSSMediaRule.cssRules, CSSStyleSheet.cssRules
Get JavaScript: The Definitive Guide, Fourth Edition now with the O’Reilly learning platform.
O’Reilly members experience books, live events, courses curated by job role, and more from O’Reilly and nearly 200 top publishers.