简体   繁体   中英

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!

因为当旋转手机时, var buttom变量会更改,从而影响jQuery的功能。

The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM