jinsuo
<!DOCTYPE html>
<html lang="zh-CN">
<head>
    <meta charset="utf-8">
    <title>Document</title>
    <style>
        .box{
            width: 100px;
            height: 100px;
            background-color: yellowgreen;
            padding: 20px;
        }
    </style>
</head>
<body>
    <div id="box" class="box"></div>
    <script>
    var oDiv = document.getElementById(\'box\');

    oDiv.onclick = function (){
        //this.style.width 获取的是行间样式(设定的也是行间样式)
        //alert(this.style.width);
        

        //  给 ie浏览器使用的  obj.currentStyle[你的属性]
        //alert(oDiv.currentStyle[\'width\']);
        
        // chrome 、firefox、ie9+
        // alert(getComputedStyle(谁,false)[attr]);
        alert(getComputedStyle(oDiv,false)[\'width\']);
    }

    </script>
</body>
</html>

 

分类:

技术点:

相关文章:

  • 2021-11-29
  • 2021-11-29
  • 2021-11-29
  • 2021-11-29
猜你喜欢
  • 2021-10-24
  • 2021-12-10
  • 2022-12-23
  • 2021-11-29
  • 2021-11-29
相关资源
相似解决方案