Find centralized, trusted content and collaborate around the technologies you use most.
Teams
Q&A for work
Connect and share knowledge within a single location that is structured and easy to search.
$(window).height()用于返回浏览器视口窗口的高度,并$(window).width()用于浏览器窗口的宽度。
$(window).height()
$(window).width()
$(window).height()现在只返回与 相同的值$(document).height(),即整个页面的高度。
$(document).height()
现在在jquery中获取视口大小的正确方法是什么?
要获取视口的宽度和高度:
var viewportWidth = $(window).width(); var viewportHeight = $(window).height();
页面调整大小事件:
$(window).resize(function() { var viewportWidth = $(window).width(); var viewportHeight = $(window).height(); });