如何获得Body元素的高度动态使用JQuery
问题描述:
我需要得到body元素的高度和宽度,当我调整浏览器窗口
I need to get the body element height and width, when i resize the browser windows
请帮我解决使用JQuery这个问题。
Please help me to solve this problem using JQuery
答
窗口对象上使用resize事件:
Use the resize event on the window object:
$(window).resize(function(){
var width = $(document).width(), // or $(window).width()
height = $(document).height(); // or $(window).height()
});