以下の関数は、ページの 10% に達したときに関数 doSomething を起動しますが、スクロールを続けると、起動し続けます。10% で発射し、その後停止するにはどうすればよいですか?
ではごきげんよう、
ジョーイ
$(document).scroll(function(e){
// grab the scroll amount and the window height
var scrollAmount = $(window).scrollTop();
var documentHeight = $(document).height();
// calculate the percentage the user has scrolled down the page
var scrollPercent = (scrollAmount / documentHeight) * 100;
if(scrollPercent = 10) {
// run a function called doSomething
doSomething();
}
function doSomething() {
$(".fill").append('<img src="img/arrow-down.png"/>');
// do something when a user gets 10% of the way down my page
}
});