getComputedStyle();

    <title>js向左滑动的轮播图</title>
    <style>
        #div1 {
            width: 200px;
            height: 200px;
            border: 1px solid #000;
        }
    </style>

</head>

<body>
<div id="div1"></div>
</body>

<script>
var div1 = document.getElementById("div1");
//console.log(getComputedStyle(div1));//获取div1所有的属性,如果想显示宽度则:getComputedStyle(div1,"width")。getComputedStyle()只能读取
console.log(getComputedStyle(div1,"width"));
</script>


 

猜你喜欢

转载自blog.csdn.net/qq_42058441/article/details/84671860
今日推荐