Here is jsFiddle for a better understanding: http://jsfiddle.net/BzYcZ/
I have a div that have scrollbars.
I want when I use mouse scrolling to stop scrolling when we get to the end of the div, rather than scrolling the entire page.
What happens is that when I get to the end of the div, the whole page will start to scroll.
I understand that this is controlled by the browser, but is there some kind of JS event that can handle this situation and prevent the whole page from scrolling, since my cursor is above this div element.
EDIT:
I want to be able to scroll the entire page, but only when my mouse is outside this div.
Decision
.noscroll { position: fixed; overflow-y: scroll; width: 100%; }
And here is the JavaScript part:
$('.small_content').hover( function () { $('body').addClass('noscroll'); }, function () { $('body').removeClass('noscroll'); } );
Here is a link to working jsFiddle: http://jsfiddle.net/BzYcZ/3/
source share