Walrus
Walrus

Reputation: 20444

DIV Overflow:scroll - disable page scroll whilst mouse is inside

Is it possible to disable the ability for the mouse wheel to scroll the page whilst it is inside a certain DIV. That way it can only scroll the div and not the page. JQuery libraries are installed so I imagine it would be something along the lines of .scroll() and stop.pagination but I do not know enough about how to do this.

Any ideas?

Marvellous

Upvotes: 3

Views: 5166

Answers (2)

Walrus
Walrus

Reputation: 20444

Fixed it.

$('.scrollable').mouseenter(function(){
                    $('body').css('overflow', 'hidden');
                });
                $('.scrollable').mouseleave(function(){
                    $('body').css('overflow', 'auto');
                });

Upvotes: 3

Naftali
Naftali

Reputation: 146310

Pure css.

For the div you want to scroll:

#divId {
    overflow: scroll;
    height: someHeight;
}

Upvotes: 0

Related Questions