在jquery的position方法,官方是这样说明的:
Get the current coordinates of the first element in the set of matched elements, relative to the offset parent.The .position() method allows us to retrieve the current position of an element relative to the offset parent. Contrast this with .offset(), which retrieves the current position relative to the document. When positioning a new element near another one and within the same containing DOM element, .position() is the more useful.jQuery does not support getting the position coordinates of hidden elements or accounting for borders, margins, or padding set on the body element.
大致意思是获得匹配元素相对于最近定位父级的距离,返回left、top值。
在CSS中有一个定位属性是比较特殊的,那就是固定属性(fixed),固定元素是相对于文档的,与页面滚动的距离无关。这一点,在jquery的1.9版本之前与1.9版本是有2种不同的解释的。关于这个区别,没有在官方的jquery升级指南里指出来,这里就抛钻引玉一下下啦。
jquery 1.9版本测试:
jquery 1.7版本测试:
您可以拉动滚动条测试,返回的值,只有jquery 1.9是正确的。那么如何在jquery 1.7版本也获得正确的结果呢?使用当前的position.top-window.scrollTop值,即为正确的结果。
敢达决战官方正版 安卓版v6.7.9
下载敢达决战 安卓版v6.7.9
下载像素火影骨架佐助 (Perseverance Fire Shadow)手机版v1.16
下载要塞英雄 安卓版v33.20.0-39082670-Android
下载梦想城镇vivo最新版本 安卓版v12.0.1
梦想城镇vivo版是这款卡通风模拟经营类手游的渠道服版本,玩
怦然心动的瞬间 安卓版v1.0
怦然心动的瞬间是一款真人向的恋爱互动游戏,在游戏中玩家将扮演
曼尼汉堡店游戏 安卓版v1.0.3
曼尼汉堡店是一款非常好玩的精品恐怖类型冒险游戏,在这款游戏中
现代总统模拟器去广告版 安卓版v1.0.46
现代总统模拟器是一款休闲养成类游戏,可能对于不少的玩家来说都
现代总统模拟器付费完整版 安卓版v1.0.46
现代总统模拟器高级版在商店是需要付费的,相对于普通版本,高级