标签:color 宽高 实现 tar ntb target 样式 bsp idt
CreateTime--2017年7月24日10:15:47
Author:Marydon
js获取高度和宽度
参考连接:http://www.cnblogs.com/EasonJim/p/6229517.html
实现方式:
style.height----offsetHeight,style.width----offsetWidth
第一种情况:
宽高都写在样式表里,就比如 #div1{width:120px;height:100px;}。
获取id=‘div1’的宽和高,如何实现?
通过document.getElementById(‘div1‘).style.height/width,返回值为空,即获取不到宽和高;
必须通过document.getElementById(‘div1‘).offsetHeight/offsetWidth
标签:color 宽高 实现 tar ntb target 样式 bsp idt
原文地址:http://www.cnblogs.com/Marydon20170307/p/7227645.html