tags:

views:

612

answers:

5

I need to add css height to each page dynamically with jquery.

So far I got the following code, but it does not add height to #wrapper.

Can anyone help me please?

Thanks in advance.

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'});
+1  A: 

You're setting the height to the string 'newheight', instead of the value of newheight. Simply get rid of the quotes:

$('#wrapper').css({'height':newheight});
Philippe Leybaert
+2  A: 

Try

$('#wrapper').css("height", newheight);
rpcutts
+1  A: 

or

$('#wrapper').css({height:newheight+'px');
adrien334
or +'em' or any other if you choose not to go with pixels (of course the logic would change from the 30 value), +1 for this tidbit
Mark Schultheiss
A: 

Or

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

So many ways to do the same thing. height method

Nooshu
A: 

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

s.wong