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

How to use jQuery to perform a Quick Search

Posted on February 27, 2018August 4, 2020 by Habibie

In this post I’m going to share a source code for performing quick search functionality using jQuery.

There is a text input and some divs. Just type a few characters then any div that doesn’t contain that characters disappear.

<!DOCTYPE html>
<html>
	<head>
		<title>ZK Tutorials</title>
		<script src="jquery-3.3.1.min.js"></script>
	</head>
	<body>
		<input id="searchinput" placeholder="Quick Search" onkeyup="quickSearch()">
		<div class="listitem">Hello...</div>
		<div class="listitem">how</div>
		<div class="listitem">are</div>
		<div class="listitem">you</div>
		<script>
			function quickSearch(){
                var keyword = $("#searchinput").val();
                keyword = keyword.toLowerCase();
                if(keyword.length > 0){
            		for(var i = 0; i < $(".listitem").length; i++){
            			if($(".listitem")[i].innerHTML.toLowerCase().indexOf(keyword) > -1) $(".listitem")[i].style.display = "block";
            			else $(".listitem")[i].style.display = "none";
            		}
            	} else $(".listitem").css({ display : "block" });
			}
		</script>
	</body>
</html>

Here is the live example:

Hello…
how
are
you


Post Views: 363
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