如何在jQuery中确定窗口的高度和滚动位置? [英] How do I determine height and scrolling position of window in jQuery?
本文介绍了如何在jQuery中确定窗口的高度和滚动位置?的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!
问题描述
我需要在jQuery中获取窗口的高度和滚动偏移量,但我没有在jQuery文档或Google中找到这个运气。
I need to grab the height of the window and the scrolling offset in jQuery, but I haven't had any luck finding this in the jQuery docs or Google.
我90%确定有一种方法可以访问一个元素的高度和scrollTop(可能包括窗口),但我找不到具体的参考。
I'm 90% certain there's a way to access height and scrollTop for an element (presumably including the window), but I just can't find the specific reference.
推荐答案
来自jQuery Docs:
From jQuery Docs:
const height = $(window).height();
const scrollTop = $(window).scrollTop();
http://api.jquery.com/scrollTop/
http://api.jquery.com/height/
这篇关于如何在jQuery中确定窗口的高度和滚动位置?的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!
查看全文