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; } });
Comments
Post a Comment