문제
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);
다른 팁
당신은 NewHeight의 가치 대신 끈 'NewHeight'로 높이를 설정합니다. 인용문을 제거하기 만하면됩니다.
$('#wrapper').css({'height':newheight});
또는
$('#wrapper').css({height:newheight+'px');
당신은 당신의 높이에 문자열 값을 할당하고, 따옴표를 제거하고 단순히 변수가 포함 된 값을 넣어야합니다. 처럼
var newheight = getPageSizeWithScroll() + 30;
$('#wrapper').css('height':newheight);
이것은 작동해야합니다 :
$('#wrapper').css({'height':newheight});
제휴하지 않습니다 StackOverflow