0

Im wondering how to disable this jquery event on mobile resolutions

$(window).scroll(function(e){
parallax();
});
function parallax(){
  var scrolled = $(window).scrollTop();
  $('.hero_image').css('top',-(scrolled*0.6)+'px');
}

I've tried a few different things from other posts on this subject but nothing seems to be doing the trick.

jwillk
  • 1

1 Answers1

0

what about using $(window).width(); so you can do something like that

$(window).scroll(function(e){
if($(window).width() > 600){
 parallax();
}
});
Mohamed-Yousef
  • 22,772
  • 3
  • 17
  • 27
  • Thanks so much. That seemed to do the trick when i tested in the brower. but once i opened the site on my phone the parallax was still being implemented and borken – jwillk Feb 12 '15 at 00:40
  • take a look at this http://stackoverflow.com/questions/3514784/what-is-the-best-way-to-detect-a-mobile-device-in-jquery?rq=1 – Mohamed-Yousef Feb 12 '15 at 00:41
  • @jwillk in your mobile you should delete cookies before you test your website again :) or you can't see any changes – Mohamed-Yousef Feb 12 '15 at 00:45