I want to make a single page website and it will have huge content. Suppose it has 1000 photos on it. I don't want people to wait 5 minutes to load my page. So I wanna add LOAD MORE button on the page bottom.
How to do that with HTML/CSS/JS?
解决方案
You could set all the divs' to display:none; at first and then use jQuery to show the first 10 (or however many you wish to show):
$(function(){
$("div").slice(0, 10).show(); // select the first ten
$("#load").click(function(e){ // click event for load more
e.preventDefault();
$("div:hidden").slice(0, 10).show(); // select next 10 hidden divs and show them
if($("div:hidden").length == 0){ // check if any hidden divs still exist
alert("No more divs"); // alert if there are none left
}
});
});
This saves you the trouble of including an entire plugin when what you want can be achieved in a few lines of code.