<!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>