Hi. Is there a way to select all CSS rules of an element with JavaScript? I'm not looking for a specific solution, just as long as all CSS rules of a given element are read.
So, I have the following HTML
<div class='styledDiv' style='height:100px;width:100px;'></div>
and then in a separate CSS file:
.styledDiv
{
background-color: #ccc;
border: solid 5px blue;
}
I'd like the final result to include all inline and separate file CSS rules. It doesn't matter in what format the final result is, be it a string or an array, whatever.
Let me also mention, I looked at some code that reads CSS rules from a separate CSS file. I think there could be a better solution. Also, FireFox and Chrome allow to loop through .style property the same way as looping through an array. However, FF spits out -*tl-source rules for right and left border/margin/padding and doesn't show the actual CSS values. Solution involving jQuery is also fine.