我需要的CSS高度与jquery动态地添加到每个页面。

到目前为止,我得到了下面的代码,但它不会增加高度#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);

其他提示

您要设置而不是newheight的价值高度,以字符串“newheight”。只要摆脱报价:

$('#wrapper').css({'height':newheight});

$('#wrapper').css({height:newheight+'px');

你是一个字符串值,以你的身高分配,所有你需要删除的报价,并把一个简单的包含变量值。像

var newheight = getPageSizeWithScroll() + 30;

$('#wrapper').css('height':newheight);

此应该工作:

$('#wrapper').css({'height':newheight});

或者

$('#wrapper').height(newheight);

这么多的方式做同样的事情。 高度方法

许可以下: CC-BY-SA归因
不隶属于 StackOverflow
scroll top