Starx Starx - 7 months ago 9
Javascript Question

How to disable scrolling of body element?

How to disable scrolling of body?

$('body').css('overflow','hidden');
only hides the scrollbars but it does not disable the scrolling. I want to disable the scrolling of the body.

But I want to keep the scrolling of other division intact.

Answer

Try this CSS, no jQuery needed for this:

<style type="text/css">
    html { overflow: hidden; }
</style>

[UPDATE after comment]

Try specifying the height of the body too:

<style type="text/css">
    html, body { overflow: hidden; height: 100% }
    body { margin:0; padding:0; }
</style>