How do I gather a class' css attributes given nothing but the className?

Posted by user1128571 on Stack Overflow See other posts from Stack Overflow or by user1128571
Published on 2012-11-11T22:32:09Z Indexed on 2012/11/11 23:00 UTC
Read the original article Hit count: 113

Filed under:
|
|

For example I might have some css stuff that looks like this:

.divType1 {
    position: absolute;
    width: 60px; height: 60px;
    left: 400px; top: 100px;
    border: 1px solid #89B;
    z-index: 0;
 }

Now within Javascript I want to gather div class divType1' css attributes, but am provided only with the div class, so I can't do something of form ( pseudo-code ):

selectDivWithClass( divType1 ).getCss(left). 

I could hack something by instantiating a div with class divType1 and grab its css attributes, and then destroy it, but is there a better way?

© Stack Overflow or respective owner

Related posts about JavaScript

Related posts about css