JavaScript jQuery scroll not working properly [duplicate] jquery scroll not working,jquery scroll not working on mobile,

When you scroll your page

 $(window).scroll(function()...

will fire multiple times. This is normal that you see multiple alerts.

Update:

It's better you do this:

var loaded = false;
$(window).scroll(function(e) {
     if(!loaded)
     {
         var hT = $(".load-more").offset().top,
             hH = $(".load-more").outerHeight(),
             wH = $(window).height(),
             wS = $(this).scrollTop();

         if (wS > (hT+hH-wH)){
             if($(".load-modre").css("display")!=="block"){
                 alert("hii");
                 loaded = true;
             }
         }
     }
});

It is also better in performance, because after loaded set to true, We have not any process in next scrolls.

Answer:1

Below code snippet to stop alerting more then one time on scroll

You can also check the link Auto Load More Data On Page Scroll (jQuery/PHP) and append results into the div

var loading = true;

$(window).scroll(function() {

	var loadMoreTop		= $('.load-more').position().top,
		loadMoreHeight	= $(".load-more").outerHeight(),
		windowScrollTop	= $(window).scrollTop(),
		windowHeight	= $(window).height()
		windowPosition	= windowScrollTop + windowHeight - loadMoreHeight;
		
	if (windowPosition >= loadMoreTop && loading) { 
		alert('Hi');
		loading = false;
	}
	
});
.container {height: 100%;}
.load-more {background: #000; padding: 10px; color: #fff;}
<script src="https://ajax.googleapis.com/ajax/libs/jquery/2.1.1/jquery.min.js"></script>

<div class="wrapper">
	<ul id="results">
	  <li>Hi</li>
	  <li>Hi</li>
	  <li>Hi</li>
	  <li>Hi</li>
	  <li>Hi</li>
	  <li>Hi</li>
	  <li>Hi</li>
	  <li>Hi</li>
	  <li>Hi</li>
	  <li>Hi</li>
	  <li>Hi</li>
	  <li>Hi</li>
	  <li>Hi</li>
	  <li>Hi</li>
	</ul>
	<div class="load-more">LOAD MORE...</div>
</div>
Answer:2

I want the input type to be folder and not a single file. How can I select a folder instead of just a single file. Also how can I then access each file in that selected folder. I tried this to select ...

I want the input type to be folder and not a single file. How can I select a folder instead of just a single file. Also how can I then access each file in that selected folder. I tried this to select ...

I'm using Fabric.js and while I can remove single objects (with "Trash" button) but would like to be able to remove any selected objects. Currently when I select more than one object nothing is ...

I'm using Fabric.js and while I can remove single objects (with "Trash" button) but would like to be able to remove any selected objects. Currently when I select more than one object nothing is ...

  1. delete selected objects django
  2. delete selected objects
  3. qgis delete selected objects
  4. failed to delete selected objects arccatalog
  5. how to delete selected objects in excel
  6. blender python delete selected objects
  7. excel delete all selected objects
  8. fabric js delete selected objects

I am having a table into which most elements are static.I however I have one <tr></tr> that i want to change dynamically using a for loop.I have only been able to add a for loop that ...

I am having a table into which most elements are static.I however I have one <tr></tr> that i want to change dynamically using a for loop.I have only been able to add a for loop that ...

I am using deckgrid in conjunction with a custom built infinite scroller to load a continuous stream of photos in Angular laid out in a masonry layout. The data set returned each time is quite large ...

I am using deckgrid in conjunction with a custom built infinite scroller to load a continuous stream of photos in Angular laid out in a masonry layout. The data set returned each time is quite large ...

  1. angular infinite scroll example
  2. angular infinite scroll table
  3. angular infinite scroll grid
  4. angular infinite scroll component
  5. angular infinite scroll list
  6. angular infinite scroll directive
  7. angular infinite scroll material
  8. angular infinite scroll select
  9. angular infinite scroll mat table
  10. angular infinite scroll cards
  11. angular infinite scroll cdk
  12. angular infinite scroll throttle
  13. angular infinite scroll
  14. angular infinite scroll not working
  15. angular infinite scroll observable
  16. angular infinite scroll http request
  17. angular infinite scroll up and down
  18. angular infinite scroll horizontal
  19. angular infinite scroll up
  20. angular infinite scroll performance