Tek-Tips is the largest IT community on the Internet today!

Members share and learn making Tek-Tips Forums the best source of peer-reviewed technical information on the Internet!

  • Congratulations Chris Miller on being selected by the Tek-Tips community for having the most helpful posts in the forums last week. Way to Go!

Use of the cssText property

Status
Not open for further replies.

BabyJeffy

Programmer
Sep 10, 2003
4,189
GB
It's always fun to stumble across something new from time to time.

I was wandering through some code today and came across a very useful property: [!]cssText[/!]. This returns any style that has been applied directly to a node (not via a CSS, but by the style="" method) as a string.

Code:
...
<div id="wibble" style="font-size: 1em; color: red; margin-left: 0.2em;">...</div>
...

Code:
...
alert(document.getElementById('wibble').style.cssText);
// alerts: font-size: 1em; color: red; margin-left: 0.2em;

This could easily be split into an array (using the semi-colon) allowing you to iterate over the individual styles.

Just thought some others might be interested in that.

Cheers,
Jeff


[tt]Jeff's Page [!]@[/!] Code Couch
[/tt]

Make sure your web page and css validates properly against the doctype you have chosen - before you attempt to debug a problem!

FAQ216-6094
 
Status
Not open for further replies.

Part and Inventory Search

Sponsor

Back
Top