我需要使用 jQuery 动态添加 css 高度到每个页面。
到目前为止,我得到了以下代码,但它没有为 #wrapper 添加高度。
function getPageSizeWithScroll(){
if (window.innerHeight && window.scrollMaxY) {// Firefox
yWithScroll = window.innerHeight + window.scrollMaxY;
xWithScroll = window.innerWidth + window.scrollMaxX;
} else if (document.body.scrollHeight > document.body.offsetHeight){ // all but Explorer Mac
yWithScroll = document.body.scrollHeight;
xWithScroll = document.body.scrollWidth;
} else { // works in Explorer 6 Strict, Mozilla (not FF) and Safari
yWithScroll = document.body.offsetHeight;
xWithScroll = document.body.offsetWidth;
}
arrayPageSizeWithScroll = yWithScroll;
//alert( 'The height is ' + yWithScroll + ' and the width is ' + xWithScroll );
return arrayPageSizeWithScroll;
}
var newheight = getPageSizeWithScroll() + 30;
$('#wrapper').css({'height':'newheight'});
最佳答案
尝试
$('#wrapper').css("height", newheight);
关于jquery - 如何使用 jQuery 添加高度到包装器?,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/1078203/