首页 > 其他 > 详细

getComputedStyle和currentStyle

时间:2015-05-27 00:43:39      阅读:211      评论:0      收藏:0      [点我收藏+]

 

 1 /*alert(div.style.width)*/ //null
 2 
 3 function getstyle(obj,name){
 4     if(obj.currentStyle) {
 5     return obj.currentStyle[name];
 6 } else {
 7     return getComputedStyle(obj,null)[name];
 8     }
 9 }
10 alert(getstyle(div,‘width‘))    
11 }

兼容ie 和非ie浏览器的获取样式写法 ;

zIndex  , marginLeft  backgroundColor 

getComputedStyle和currentStyle

原文:http://www.cnblogs.com/web-alibaba/p/4532123.html

(0)
(0)
   
举报
评论 一句话评论(0
关于我们 - 联系我们 - 留言反馈 - 联系我们:wmxa8@hotmail.com
© 2014 bubuko.com 版权所有
打开技术之扣,分享程序人生!