javascript - jquery中offsetTop和offset().top什么区别
阿神
阿神 2017-04-10 16:15:07
[JavaScript讨论组]

jquery中offsetTop和offset().top什么区别?
谢谢

阿神
阿神

闭关修行中......

全部回复(2)
PHP中文网

http://stackoverflow.com/questions/6777506/offsettop-vs-jquery-offset-top 有解答

This is what jQuery API Doc says about .offset():

Get the current coordinates of the first element, or set the coordinates of every element, in the set of matched elements, relative to the document.

This is what MDN Web API says about .offsetTop:

offsetTop returns the distance of the current element relative to the top of the offsetParent node

PHPz

1) offset();方法获取的元素相对于当前document元素的位置,可以将其理解为一个绝对位置
2) offsetTop为一个元素相对于器offsetParent的top位置。
3) offsetParent为元素的中距离其最近的一个父元素,这个父元素的position属性为absolute或relative的
4) offsetParent可以通过jQuery的offsetParent()方法获取

热门教程
更多>
最新下载
更多>
网站特效
网站源码
网站素材
前端模板
关于我们 免责申明 意见反馈 讲师合作 广告合作 最新更新 English
php中文网:公益在线php培训,帮助PHP学习者快速成长!
关注服务号 技术交流群
PHP中文网订阅号
每天精选资源文章推送
PHP中文网APP
随时随地碎片化学习
PHP中文网抖音号
发现有趣的

Copyright 2014-2025 https://www.php.cn/ All Rights Reserved | php.cn | 湘ICP备2023035733号