Is there a way to select all CSS rules for an element with JavaScript? I am not looking for a specific solution until all CSS rules for this 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 want the end result to include all the inline and individual CSS file rules. It doesn't matter what format the end result is in, whether it's 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 might be a better solution. In addition, FireFox and Chrome allow you to scroll through the .style property in the same way as looping through an array. However, FF spills out - * tl-source rules for left and right border / field / padding and does not display actual CSS values. The jQuery related solution is also great.
source
share