Subscribe - It's FREE!!

Stay Connected Here

Stay Updated With Us Here


How to use select2 jQuery Multiselect dropdown with Bootstrap 3

Share with WhatsApp

This post I will cover information about how you can use select2 multiselection dropdown with Bootstrap 3. This jQuery plugin so useful that if you use it in your ASP.NET MVC application then it will definetely add nice user experience to your application.

If you are not aware about "Select2" then I will recommend to visit "Select 2 Website" and know more about it and its features.

I am assuming now you are aware it and now I will let you know how you can use it along with Bootstrap 3. 

First you have to add "Select2" js and css in your HTML page which you can download from here.

Then suppose you have added a html mark up like following.

<select id="ddlCars" multiple="multiple" style="width:300px">
<option value="Accord">Accord</option>
<option value="Duster">Duster</option>
<option value="Esteem">Esteem</option>
<option value="Fiero">Fiero</option>
<option value="Lancer">Lancer</option>
<option value="Phantom">Phantom</option>

Now to convert above ordinary input to "Select 2" multi select searchable input then you need to write a simple jQuery code like below.

    placeholder: "Select a Cars.."

Now if you run this example you will find a awesome multiselection dropdown. 

Check out the live fiddle below which has shown a use of select2 for single selection, multiple selection and with custom css.

In below live fiddle I have used one more css which makes "Select2" very much compatible to Bootstrap without any UI related issues. Thanks to the author to make this CSS available for us as it makes Select2 bootstrap friendly along with some more useful css classes which helps you to implement "Select2" in more efficient way. Read more about its usage and settings here.

Hope you have liked this simple post. Thanks.

If you enjoyed this post take 5 seconds to share it! Be Socialable. :-)

Share with WhatsApp

Posts To Read Next

Swagger - Powerful Opensource Framework for RESTful API

With a Swagger-enabled API, you get interactive documentation, client SDK generation and discoverability. Swagger Editor allows you to generate code, documentation with ease.

What is Hoisting in JavaScript?

Hoisting in JavaScript, one of the most misunderstood or little understood concept in the JavaScript and remain famous as interview question for JavaScript developers and now also for angular js developer. Lets check out what it means exactly.

Visual Studio Code - Lighweight but powerful source code editor available for Windows, OS X and Linux

Visual Studio Code is a lightweight but powerful source code editor which runs on your desktop and is available for Windows, OS X and Linux. It comes with built-in support for JavaScript, TypeScript and Node.js and has a rich ecosystem of extensions for other languages (C++, C#, Python, PHP) and runtimes.

How to post JSON string as a string in jQuery AJAX

Know how to post JSON String as string to the action method of controller in MVC.

How to call click or any event only once in jQuery

Know how to execute an click event or any event only once for any element in jQuery. Perform action only once and even not required to unbind event.

Your opinion is valuable for us! Comments, suggetions are welcome.

Submit your Email Id to stay updated with us and get notified with our new posts. It's FREE!
Vu 32'' TV Vu 24'' TV
We know this popup is disturbing you!
But We would greatly appreciate if you share us with your friends below!

It will not take more than 2 seconds but will motivate us greatly to write more,share more!