Search is an useful feature for a HTML dropdown list. Especially it will increase user convenience to select items from the dropdown having long list. In this tutorial, we are going to list country dropdown with a search option. In previous tutorial we have seen countries and its dependent dropdown list.
This code contains a HTML select element referred by its id. With this id reference it invokes select2 function to show this dropdown list with a search box. While invoking this function we are passing an array of country list to the target dropdown element.
We can also pass remote data to the dropdown from database or any other data source dynamically. There are many options to provide dropdown list search with added features. For example we can control the minimum number of input charactors we have to type for start searching.
This jQuery code tutorial was published on January 12, 2016.