getComputedStyle text-decoration inherit

Posted by Guilherme Nascimento on Stack Overflow See other posts from Stack Overflow or by Guilherme Nascimento
Published on 2013-11-03T06:31:21Z Indexed on 2013/11/03 15:53 UTC
Read the original article Hit count: 242

Filed under:
|
|
|

getComputedStyle fails to get text-decoration property inherited, but can get font-size.

Failed in Firefox 25 and GoogleChrome 30.

Note: In Internet Explorer 10 work!

<!DOCTYPE html>
<html>
    <style>
        #parent
        {
            font-size: 38px;
            text-decoration: underline;
        }
    </style>
<body>
    <div id="parent">
        <p id="child">Test</p>
    </div>
    <script>
        var elem = document.getElementById("child");

        document.write("text-decoration:"+window.getComputedStyle(elem).getPropertyValue("text-decoration"));
        document.write("<br>");
        document.write("text-decoration:"+document.defaultView.getComputedStyle(elem).getPropertyValue("text-decoration"));
        document.write("<hr>");
        document.write("font-size:"+window.getComputedStyle(elem).getPropertyValue("font-size"));
        document.write("<br>");
        document.write("font-size:"+document.defaultView.getComputedStyle(elem).getPropertyValue("font-size"));
    </script>
</body>
</html>

It is a fault of mine, or browsers that failed?

© Stack Overflow or respective owner

Related posts about JavaScript

Related posts about css