Answers for "load more button javascript"

0

load more button javascript

$(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
        }
    });
});
Posted by: Guest on March-04-2021
0

Load more button

<!DOCTYPE html>
<html lang="en">
<head>
    <title>How To Create Javascript Load More Content On Click Button</title>
    <meta charset="utf-8">
    <meta name="viewport" content="width=device-width, initial-scale=1">
</head>
<body>
	<!-- List of your items -->
	<div class="list">
	    <div class="list-element">Product 1</div>
	    <div class="list-element">Product 2</div>
	    <div class="list-element">Product 3</div>
	    <div class="list-element">Product 4</div>
	    <div class="list-element">Product 5</div>
	    <div class="list-element">Product 6</div>
	</div>

	<!-- Load More Button -->
	<button id="loadmore">Load More...</button>
</body>
</html>
Posted by: Guest on September-03-2021

Code answers related to "Javascript"

Browse Popular Code Answers by Language