Subscribe - It's FREE!!

Stay Connected Here

Stay Updated With Us Here



Google

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>
</select>

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

$("#ddlCars").select2({
    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

Top 10 Visual Studio things which can boost developers coding speed

Visual Studio 2012 provides some coding features by which you can code faster if use them properly. This post will cover top 10 things among them to boost your development speed.


Visual Studio 2008 Shell and TFS integration

Visual Studio 2008 Shell and TFS integration is the problem for all newbies of BIDS and TFS. Here is the solution.


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.


Assembla - Free and private repository to manage your source code online with SVN subversion hosting

With Assembla you can share source code with others online. Free & Private source code repository with SVN Subversion, Git & Perforce Hosting.


Best CSS Gradient background generator tools online

Here are some best CSS gradient background code generator online tools using which you can create a cross browser css code for gradient backgrounds.


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!
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!

x