Skip to content

ThirteeNov

My personal blog about coding and internet

Menu
  • About me
  • About Zofia Kreasi
  • Cart
  • Checkout
  • Making an airplane game from scratch in Unity
  • My account
  • Privacy Policy
  • Privacy Policy – zkLeaderboard
  • Sample Page
  • Shop
  • Tutorials on Learning JavaScript
  • ZKAccounts – Privacy Policy
Menu

Tutorial on Creating HTML5 and JavaScript Load More Button

Posted on July 2, 2019August 4, 2020 by Habibie

In this video tutorial I’m sharing about how to create “Load More” button in JavaScript to show partial contents of an array variable.

Please note that in this technique first I retrieve all the information from server at single shot and store it in single array variable. So load more mechanism is happening on client side, not each time calling server to return partial contents.

Watch this video demonstration:

I am using jQuery for this code, so you need to include jQuery first. And here is the actual code:

<div id="content"></div>
<button id="lmbutton" onclick="loadmore()">Load More</button>
<script>
	var items = ["one", "twp", "three", "four", "five", "six", "seven", "eight", "nine", "ten"]
	var currentindex = 0
	function loadmore(){
	var maxresult = 2
		for(var i = 0; i < maxresult; i++){
			if(currentindex >= items.length){
				$("#lmbutton").hide()
				return
			}
			$("#content").append("<div>"+items[i+currentindex]+"</div>")
		}
		currentindex += maxresult
	}
	loadmore()
</script>
Post Views: 389
ciihuy2020

Welcome!

  • My YouTube Channel
  • My GitHub Page
  • About me

Categories

  • 3DVista
  • Android
  • Apache
  • C#
  • Cordova
  • Electron & Node JS
  • HTML5, CSS & JavaScript
  • iOS
  • Let's Make Unity Games
  • Misc
  • Photoshop
  • PHP
  • Python
  • Uncategorized
  • Unity
  • WordPress

Recent Posts

  • Hover Reveal script for Unity to show and hide object on mouse hover
  • How to Prevent UI Clicks in Unity from “Bleeding Through” to 3D Objects Behind Them
  • Make objects like wires and cables easily in Unity using Ciihuy Curved Mesh
  • [SOLVED] Can’t Add Custom Domain to Blogger After Losing CNAME Verification
  • iOS App Icon Generator by CiihuyCom
© 2026 ThirteeNov | Powered by Superbs Personal Blog theme