If you are worried about perfomance then store document.styleSheets and document.styleSheets.length in a variable and iterate over them. I believe document.styleSheets is a dynamic list so it will be recalculated every time you access it so it's expensive to do it the way you have done.
On Tue, Feb 24, 2009 at 12:13 AM, Detlef <[email protected]> wrote: > > Given some STYLE, say > <STYLE type=text(css> > .mySyle { color:#335577 } > and given some DOM element, say > <DIV ID="" CLASS="myStyle">This is a DIV</DIV> , > with the expression > document.getElementById("myDivElement").className > I can find out the css-class of that DIV, in this case > "myStyle" . > > With the loop > for (i=0; i<document.styleSheets.length; i++) > { > for (j=0; j<document.styleSheets[i].cssRules.length; j++) > { > theName = document.styleSheets[i].cssRules[j].selectorText; > theStyle = document.styleSheets[i].cssRules[j].cssText; > theColor = document.styleSheets[i].cssRules > [j].style.color; } } > I can loop over and find all the style names, in this case just > 'myStyle', and the variable 'theStyle' will carry all the properties > belonging to that style, and theColor will carry the Text color of > that style. > > Question: > Is there a direct access "tellStyle", or s.th. like that, within the > DOM, so I can obtain the text color directly by writing something like > myColor = tellStyle("myStyle").color ? > > TIA for hints! > Detlef Lindenthal > > > > --~--~---------~--~----~------------~-------~--~----~ You received this message because you are subscribed to the Google Groups "Firebug" group. To post to this group, send email to [email protected] To unsubscribe from this group, send email to [email protected] For more options, visit this group at http://groups.google.com/group/firebug?hl=en -~----------~----~----~----~------~----~------~--~---
