首页 > 其他 > 详细

.style, .getComputedStyle(),.currentStyle区别

时间:2016-03-01 10:54:51      阅读:82      评论:0      收藏:0      [点我收藏+]

1)style只能获取行间样式(写在标签里面的);能读能写

2)currentStyle是专属ie的属性,区别他返回的是最终样式 及包括行间和外链css

3)getComputedStyle是一个可以获取当前元素所有最终使用的CSS属性值;只读

因此:

行间样式可以直接用style;其他可用函数

 var oStyle = this.currentStyle? this.currentStyle : window.getComputedStyle(this, null);
    alert(oStyle.height);

.style, .getComputedStyle(),.currentStyle区别

原文:http://www.cnblogs.com/chabai/p/5230049.html

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