Search Bar with Suggestions using jQuery Autocomplete.js

The “Autocomplete” is a well designed, multi-features and cross-browser plugin for jQuery. It helps you to create jQuery powered search bar with suggestions. You just need to define an array of suggested words that you wanted to display as search hints. After that, the plugin will dynamically started to suggest words on input event.

Moreover, the plugin comes with multiple configuration options. You can fully customize it according to your needs.

Plugin Overview

Plugin: Autocomplete.js
Author: Lorenzo Cioni
Licence: MIT Licence
Published: January 17, 2024
Repository: Fork on GitHub
Dependencies: jQuery 1.3.1 or Latest version
File Type: zip archive (HTML, CSS & JavaScript )
Package Size: 76.5 KB

How to Make jQuery Search Bar with Suggestions

1. Load jQuery JavaScript library and Autocomplete plugin’s CSS and JS file into your HTML document.

<!-- jQuery -->
<script src=""></script>

<!-- Autocomplete JS -->
<script src="js/autocomplete.js"></script>

<!-- Autocomplete CSS -->
<link rel="stylesheet" href="css/autocomplete.min.css">

2. After loading all necessary assets, create a div element with a unique id for search bar as follows:

<div class="wrapper">
   <div id="search-form"></div>

3. Now, create an array of your suggestions words in jQuery document ready function and then initialize the plugin.


var suggestions = ['Apple', 'Banana', 'Mango', 'Orange', 'Grips'];

      hints: suggestions 


Advance Configuration Options for Suggestions Search Bar

The following are some advance configuration options to create / customize “jQuery search bar with suggestions”.

Option Description, Default, Type

Define the an array of words for suggestions / hints. Default: [], Type: Array.

   hints: ['Apple', 'Banana', 'Mango', 'Orange', 'Grips'],

Define the placeholder text for search input. Default: “Search”, Type: String.

   placeholder: "Your custom placeholder text",
width & height

These are useful to define the CSS width and height property for search input. Default: width: 200, height: 16, Type: Number | String.

Tip: You can also define width & height in px, em or any valid CSS value. To do so, pass the value in string. Like: “140px”

   width: 300,
   height: 24,

Enable / disable search button. Default: true, Type: Boolean.

false to disable.

   showButton: true.

It define the text on/for search button. Default: “Search”, Type: String.

   buttonText: "Custom Text",

Autocomplete JS Callback Functions

The following are two callback functions to execute on different search (input) events.

1. Function to trigger on search submit.

   onSubmit: function(){
	  //Code to execute

3. Function to trigger on input blur.

   onBlur: function(){
	 //Code to execute

Leave a Comment

This site uses Akismet to reduce spam. Learn how your comment data is processed.

About CodeHim

Free Web Design Code & Scripts - CodeHim is one of the BEST developer websites that provide web designers and developers with a simple way to preview and download a variety of free code & scripts. All codes published on CodeHim are open source, distributed under OSD-compliant license which grants all the rights to use, study, change and share the software in modified and unmodified form. Before publishing, we test and review each code snippet to avoid errors, but we cannot warrant the full correctness of all content. All trademarks, trade names, logos, and icons are the property of their respective owners... find out more...

Please Rel0ad/PressF5 this page if you can't click the download/preview link