开发者

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

开发者 https://www.devze.com 2023-04-08 20:29 出处:网络
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

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?

Marve开发者_如何转开发llous


Fixed it.

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


Pure css.

For the div you want to scroll:

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

精彩评论

暂无评论...
验证码 换一张
取 消