Print Friendly

# Class YAHOO.ext.util.CSS

Package: | YAHOO.ext.util
Class: | CSS
Extends: | Object
Defined In: | CSS.js

Class for manipulating CSS Rules
This class is a singleton and cannot be created directly.

## Public Properties

This class has no public properties.

## Public Methods

Method | Defined By
--- | ---
| apply(`HTMLElement el`, `String/Array selector`) : Boolean | CSS
Applies a rule to an element without adding the class
| getRule(`String/Array selector`, `Boolean refreshCache`) : CSSRule | CSS
Gets an an individual CSS rule by selector(s)
| getRules(`Boolean refreshCache`) : Object | CSS
Gets all css rules for the document
| updateRule(`String/Array selector`, `String property`, `String value`) : Boolean | CSS
Updates a rule property

## Public Events

This class has no public events.

## Method Details

### apply

`public function apply(`HTMLElement el`, `String/Array selector`)`
Applies a rule to an element without adding the class
Parameters:

- `el` : HTMLElement
  The element
- `selector` : String/Array
  If it's an array it tries each selector until it finds one. Stops immediately once one is found.

Returns:

- `Boolean`
  true if a rule was found and applied

This method is defined by CSS.

### getRule

`public function getRule(`String/Array selector`, `Boolean refreshCache`)`
Gets an an individual CSS rule by selector(s)
Parameters:

- `selector` : String/Array
  The CSS selector or an array of selectors to try. The first selector that is found is returned.
- `refreshCache` : Boolean
  true to refresh the internal cache

Returns:

- `CSSRule`
  The CSS rule or null if one is not found

This method is defined by CSS.

### getRules

`public function getRules(`Boolean refreshCache`)`
Gets all css rules for the document
Parameters:

- `refreshCache` : Boolean
  true to refresh the internal cache

Returns:

- `Object`
  An object (hash) of rules indexed by selector

This method is defined by CSS.

### updateRule

`public function updateRule(`String/Array selector`, `String property`, `String value`)`
Updates a rule property
Parameters:

- `selector` : String/Array
  If it's an array it tries each selector until it finds one. Stops immediately once one is found.
- `property` : String
  The css property
- `value` : String
  The new value for the property

Returns:

- `Boolean`
  true if a rule was found and updated

This method is defined by CSS.

yui-ext - Copyright © 2006 Jack Slocum. | Yahoo! UI - Copyright © 2006 Yahoo! Inc.
All rights reserved.