How to add height to wrapper with jquery?
Question
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'});
Solution
Try
$('#wrapper').css("height", newheight);
OTHER TIPS
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});
or
$('#wrapper').css({height:newheight+'px');
you are assigning a string value to your height, all you need to remove quotes and put simply a variable containing value. like
var newheight = getPageSizeWithScroll() + 30;
$('#wrapper').css('height':newheight);
This should work:
$('#wrapper').css({'height':newheight});
Licensed under: CC-BY-SA with attribution
Not affiliated with StackOverflow