document.styleSheets[0]是个啥

<!DOCTYPE html>
<html>
    <head>
        <meta charset="UTF-8">
        <title></title>
        <link rel="stylesheet" href="css/css.css" />    
        <style>
        .css01{
            background-image: url(img/01.png);
        }
        </style>
        <script>
        // 无论link还是<style></style>,从前往后依次是0,1,2……
        alert(document.styleSheets[0].rules[0].style.backgroundImage);
        alert(document.styleSheets[1].rules[0].style.backgroundImage);
        </script>
    </head>

    <body>
        <input type="file" id="inputFile" onchange="GetFilePath()" />
    </body>
</html>

 

你可能感兴趣的:(document.styleSheets[0]是个啥)