/** * 2013-08-04-经过JS获取CSS属性的值 * [div description] * @type {[type]} */ var div = document.getElementById("mydiv"); //1.获取行内样式表中CSS的值 alert(div.style.width); //2.获取内嵌样式表和外部样式表中CSS的值 if(document.defaultView) { //非IE浏览器 var style = document.defaultView.getComputedStyle(div,null); alert(style.width); } else if(div.currentStyle) { //IE浏览器 alert(div.currentStyle.width); }