function getstyle(obj, style) {
if(obj.currentStyle){
return obj.currentStyle[style] //ie下获取样式
}else {
return document.defaultView.getComputedStyle(obj,null)[style]//谷歌,火狐下获取默认样式
}
}
var d=document.getElementsByClassName("demo")[0];
console.log(getstyle(d,"width"));