Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

Prevent scroll event in jQuery

Tags:

jquery

scroll

Is it possible to prevent scroll event in jQuery?

I've tried this code, but it didn't work.

$('*').scroll(function(event){
  event.stopPropagation();
  event.preventDefault();
  return false;
})
like image 263
Denis Avatar asked Jun 25 '12 08:06

Denis


1 Answers

You can disable scrolling within certain element areas using the following:

$("element,element2").bind("touchmove",function(e){
    e.preventDefault();
});
like image 98
kaleazy Avatar answered Sep 30 '22 20:09

kaleazy