aserww106
aserww106

Reputation: 1341

why does my jquery code not work on mobile browser

I'm using jquery and my code is like this:

$(window).scroll(function(){
  var bottom = $("div#theid").offset();

  if ( bottom.top - $(window).scrollTop() < 650 ) {
  //do something here
  }

});

so when scroll down the browser, will do something, this works just fine on desktop browser, but not on mobile browser, but if I rotate my phone , this code will work, very strange. Why this strange thing happen? Thank you!

Upvotes: 0

Views: 80

Answers (1)

Jan Anderssen
Jan Anderssen

Reputation: 95

Because when you rotate your phone, the var buttom variable changes which effects jQuery to function.

Upvotes: 1

Related Questions