js获取样式的方式

来源:互联网 发布:sai for mac 中文 编辑:程序博客网 时间:2024/05/21 09:54

js获取样式的方式

ie和主流浏览器的

// 获取样式 function getStyle(el,sty){     var getIt;     if(window.getComputedStyle){         getIt= window.getComputedStyle(el,null)[sty]     }else{         getIt=el.currentStyle[sty] //IE获取样式的方法     }     return getIt }    console.log(parseInt(getStyle(box,'fontSize')));

原创粉丝点击