jquery - 如何使用 jQuery 添加高度到包装器?

标签 jquery css height

我需要使用 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/

相关文章:

jquery - 网页的持久标题

javascript - 访问函数/对象中的 $ ('selector' ).data

用于切换图像切换按钮类的Javascript

css - 定义 div 框(底部)与不同分辨率的高度

javascript - 创建具有自动调整大小的文本区域

css - 具有可拉伸(stretch)高度的 2 列 CSS div

javascript - jQuery addClass 和标准 classList.addClass 有什么区别?

javascript - 无法从 iframe 关闭颜色框窗口

html - 仅 CSS : <div> that fills up <th> parent

java - 为什么按钮在点击时调整大小