獲取樣式
obj.style.width 只能取到行間樣式
getComputedStyle: 計(jì)算后的(生效的)樣式
用法:
getComputedStyle(obj,false).樣式 ;
--false: 偽類 偽元素
兼容性:
Chrome FF IE9+
不兼容:ie8 ie7 ..以下
obj.currentStyle.樣式;
兼容性:IE 整個(gè)系列
不兼容 Chrome FF ---> undefined
function getStyle(obj,name){
if (obj.currentStyle){//ie
return obj.currentStyle[name];
}else{
return getComputedStyle(obj,false)[name];
}
}