5

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;
})
JJJ
  • 32,902
  • 20
  • 89
  • 102
Denis
  • 2,429
  • 5
  • 33
  • 61

3 Answers3

7

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

$("element,element2").bind("touchmove",function(e){
    e.preventDefault();
});
kaleazy
  • 5,922
  • 2
  • 47
  • 51
2

Just set the body CSS to disable the scroll.

body {    
   overflow: hidden; 
}
Siva Charan
  • 17,940
  • 9
  • 60
  • 95
  • thanks, it would work but not in my case.. i'm looking for something like to catch "keycode" or "scroll" event and pervent this. and i have to do this on mobile devise "Samsung", any ideas? – Denis Jun 25 '12 at 09:01
0

well.. i worked with wrong event. touchmove was exactly what i'm looked for. so

$('body').bind('touchmove', function(e){
  e.preventDefault();
});
Denis
  • 2,429
  • 5
  • 33
  • 61