javascript,如何获取元素的 width height left top?
javascript吧
全部回复
仅看楼主
level 5
在考虑兼容性问题,创建或未创建该元素,该元素的style是写在元素内还是写在css内的情况下,如何获取元素的width,height,margin-top,还有绝对定位的top.
有没有人总结过上面的资料啊.
上图的offsetTop 无法获取到....
2013年09月08日 04点09分 1
level 5
没有人吗?
2013年09月08日 06点09分 2
....
2013年09月08日 08点09分
level 9
currentStyle 和getComputed();
2013年09月08日 08点09分 3
这个不是不支持IE吗
2013年09月08日 15点09分
回复 我真的是熊T :不是写了两个么?这两个一起用不就兼容了
2013年09月08日 15点09分
level 2
offset是只读的。不能改
2013年09月08日 11点09分 4
level 9
function css(obj, attr) {
if (obj.currentStyle) {
return obj.currentStyle[attr];
} else {
return getComputedStyle(obj, false)[attr];
}
}
2013年09月08日 15点09分 5
level 7
楼主什么浏览器不兼容"offsetTop"?本人测试过 chrome ie都能打印出“offsetTop”属性。
2013年09月08日 15点09分 6
level 7
对了,忘了贴图:
2013年09月08日 15点09分 7
1