jquery如何获取页面当前屏幕顶部位置?
如果我将鼠标滚轮滚动到页面的某个部分,如何获取页面当前的顶部位置?
我想单击页面中的一个元素,然后打开一个顶部位于当前屏幕顶部的 div。
所以只需将当前屏幕顶部位置设置为:
$('#content').css('top','current position');
和
#content
{
position:absolute;
left:100px;
}
最佳答案
使用它来获取页面滚动位置。
var screenTop = $(document).scrollTop();
$('#content').css('top', screenTop);
关于jquery如何获取页面当前屏幕顶部位置?,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/7019353/