parentNode 父级元素,不管定位
offsetParent(去除html和body的margin和padding影响):
1.元素定位fixed:
1.offsetParent是null(IE)
2.offsetParent是body(火狐)
2.元素定位不是fixed:
1.父元素有定位:offsetParent是父级
2.父元素无定位:offsetParent是body
offsetLeft和offsetTop所有dom元素都有,基于offsetParent,并计算他的padding。






网友评论