jquery - $(window).scroll() Loop, due to no variable -


i have bit of problem; have code:

  $(window).scroll(function(){     if ($(document).scrolltop() >= $('.services-container').offset().top-80) {       alert("test");     }   }); 

now works ok, except need run if statement once, tried variables cannot them not re-set previous state due window scroll loop... help?

you can try flag:

var flag = true;  $(window).scroll(function() {     if ($(document).scrolltop() >= $('.services-container').offset().top-80 && flag) {        alert("test");        flag = false;     } }); 

demo fiddle


Comments

Popular posts from this blog

android - Get AccessToken using signpost OAuth without opening a browser (Two legged Oauth) -

org.mockito.exceptions.misusing.InvalidUseOfMatchersException: mockito -

google shop client API returns 400 bad request error while adding an item -