jQuery如何获取页面当前屏幕的顶部位置? [英] jquery how to get the page's current screen top position?
本文介绍了jQuery如何获取页面当前屏幕的顶部位置?的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!
问题描述
jquery如何获取页面当前屏幕的顶部位置?
jquery how to get the page's current screen top position?
如果将鼠标滚轮滚动到页面的某个部分,如何获得页面的当前顶部位置?
If I scroll my mouse wheel to some part of the page, how do I get the page's current top position?
我要单击页面中的一个元素,然后打开一个div,其顶部是当前屏幕的顶部.
I want click one element in my page, then open a div which top is to current screen top.
因此,只需将当前屏幕的顶部位置放在:
So just put the current screen top position to:
$('#content').css('top','current position');
还有
#content
{
position:absolute;
left:100px;
}
推荐答案
var top = $('html').offset().top;
应该这样做.
这是$(document).scrollTop()
这篇关于jQuery如何获取页面当前屏幕的顶部位置?的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!
查看全文