Pure Java Script Search box

Pure Javascript Search Functionality

Hi all, here I am with a search bar using this you can search the content of their concern. A basic search bar we can make by using Html, CSS & Javascript only. There are many advance search functionality that uses algorithm base search to show up results. But the search function that we are going to make will filter substrings in the string.

Lets code this Searchbox functionality.

HTML Code:

In this html we remind one thing we must have different data string for each recurrence so that when we search item it can differentitate for visible output.

CSS Code:

Going to make this layout beautiful as be know beauty is best.

Javascript code:

When we give this search bar any input on keypress id=”search-users” called, in this way our javascript code works on every keypress. First of all we get input using querySelector for input field ID and make sure you convert it in lowercase to avoid case sensivity while searching. A arrary of data stored in userData. This contains everylist that has class “user”. After this loops runs to check if innerHTML of every document includes the input substring if it does not, display set to none so that it can be hidden from front end.

Leave a Reply

Your email address will not be published. Required fields are marked *