stop scrolling of webpage with jquery

2019-02-20 15:03发布

问题:

I am using a query bumpbox plugin with the webpage, I am working on but I can still scroll away from the bumpbox when I am using it. I was wondering if there was some sort of jquery method that will keep the webpage from scrolling or just scroll the opposite way with the same distance that the user scrolled.

回答1:

It's hard to be specific with no code posted, but to prevent scrolling you could do something like :

$(window)​​.on('scroll', function() {
    $(this).scrollTop(100); //sets the scrollposition to 100px
})​​;​

FIDDLE



回答2:

Easiest way to achieve this

$("body").css("overflow", "hidden");