23.04.2013 Views

javascript

javascript

javascript

SHOW MORE
SHOW LESS

Create successful ePaper yourself

Turn your PDF publications into a flip-book with our unique Google optimized e-Paper software.

CHAPTER 8 ■ SCRIPTING CSS<br />

334<br />

Figure 8–12. Deleting the two newly inserted rules with deleteRule() swaps the sprite from green to<br />

fuchsia to blue.<br />

Querying Overall Styles from the Cascade<br />

Now then, what if you want to query the overall styles from the CSS cascade for an element? In other<br />

words, you want to know the declarations that have the highest precedence. Those form one<br />

humongous declaration block, which, like the declaration block for a rule, JavaScript represents with a<br />

CSSStyleDeclaration object. You already know how to query those cumulative declarations—the.<br />

operator and a CSS2Properties member. Remember they are camel case, not dash case. On the other<br />

hand, CSSStyleDeclaration.cssText contains the declarations block, minus the curly braces, as a string.<br />

However, this string is oftentimes too lengthy to bother with.<br />

The cumulative declaration block from the cascade differs from that of a rule in a style sheet in a few<br />

ways:<br />

p

Hooray! Your file is uploaded and ready to be published.

Saved successfully!

Ooh no, something went wrong!