How to retrieve a style's value in javascript?
        Posted  
        
            by stan
        on Stack Overflow
        
        See other posts from Stack Overflow
        
            or by stan
        
        
        
        Published on 2010-04-18T21:30:01Z
        Indexed on 
            2010/04/18
            21:33 UTC
        
        
        Read the original article
        Hit count: 378
        
I am looking for a way to retrieve the style from an element that has a style set upon it by the style tag.
<style> 
#box {width: 100px;}
</style>
In the body
<div id="box"></div>
I'm looking for straight javascript without the use of libraries.
I tried the following, but keep receiving blanks:
alert (document.getElementById("box").style.width);  
alert (document.getElementById("box").style.getPropertyValue("width"));
I noticed that I'm only able to use the above if I have set the style using javascript, but unable to with the style tags.
© Stack Overflow or respective owner