//谷歌,火狐支持
console.log(window.getcomputedstyle(my$("dv"),null).left);
//ie8支持
console.log(my$("dv").currentstyle.left);
//获取任意一个元素的任意一个样式属性的值 function getstyle(element,attr) { //判断浏览器是否支持这个方法 if(window.getcomputedstyle){ return window.getcomputedstyle(element,null)[attr]; }else{ return element.currentstyle[attr]; } }
简化
function getstyle(element,attr) { return window.getcomputedstyle? window.getcomputedstyle(element,null)[attr]:element.currentstyle[attr]; }
您可能感兴趣的文章:
如您对本文有疑问或者有任何想说的,请 点击进行留言回复,万千网友为您解惑!
网友评论