The body of the document is a magic element and does not behave the way other HTML elements do. Your code:
$('body').height(100);
That's right, and it is the same as:
$('body').css({height: 100}); $('body').css({height: '100px'}); $('body').attr({style: 'height: 100px'});
All results:
<body style="height: 100px;">
However, setting the height will not hide the area located outside the 100px height, invisible. You should wrap the contents of the body inside the div and set it instead:
<body> <div id="wrapper" style="height: 100px; overflow: hidden;"> </div> </body>
A jQuery solution would be:
$("body").wrapInner($('<div id="height-helper"/>').css({ height: 100, overflow: "hidden" }));
source share