jQuery multiple select plugin for Bootstrap
Last Updated :
17 Aug, 2021
jQuery provides a variety of plugins for bootstrap for distinctive purposes which can be easily integrated into a web application, making the websites and applications look more attractive and reliable.
Plugins can be included in two ways i.e. individually by using Bootstrap's individual *.js files, or all at once, utilizing bootstrap.js.
Bootstrap multiselect is also one of the jQuery plugins for Bootstrap, which enables the client to choose more than one alternative from a dropdown list, at once. Utilizing the multiple select plugins, dropdown alternatives act as checkboxes, so that the client can choose multiple alternatives, unlike normal dropdown where only one alternative can be chosen. The plugin is based on the Twitter Bootstrap system and comes with numerous features. In runtime, simple HTML select can be effortlessly changed into a Bootstrap button by utilizing the same.
You need to add the following resources to your HTML file to use the bootstrap multiple select jQuery plugin in your website.
- Stylesheet to enable the alternatives to be opened as a dropdown.
<link href="https://maxcdn.bootstrapcdn.com/bootstrap/3.3.6/css/bootstrap.min.css" rel="stylesheet">
- Include Bootstrap and jQuery files as scripts.
<script src="http://ajax.googleapis.com/ajax/libs/jquery/1.9.1/jquery.js"></script>
<script src="https://maxcdn.bootstrapcdn.com/bootstrap/3.3.6/js/bootstrap.min.js"></script>
- Bootstrap CDN links to enable the multi-select feature in the dropdown list.
<script
src="https://cdnjs.cloudflare.com/ajax/libs/bootstrap-multiselect/0.9.13/js/bootstrap-multiselect.js">
</script>
<link
href="https://cdnjs.cloudflare.com/ajax/libs/bootstrap-multiselect/0.9.13/css/bootstrap-multiselect.css"
rel="stylesheet" >
- Now create an HTML dropdown with a list of alternatives.
<select id="checkboxes" multiple="multiple">
<option value="Array">Array</option>
<option value="Linked list">Linked list</option>
<option value="Strings">Strings</option>
<option value="Stack">Stack</option>
<option value="Queue">Queue</option>
<option value="Graph">Graph</option>
<option value="Tree">Tree</option>
<option value="Maps">Maps</option>
</select>
- And don't forget to initialize the plugin by calling the multiselect() function.
$('#checkboxes').multiselect();
After initializing the plugin, the selected dropdown component ($('#checkboxes')) will be replaced with a bootstrap button that shows available options with checkboxes.
Example:
HTML
<html>
<head>
<script src=
"http://ajax.googleapis.com/ajax/libs/jquery/1.9.1/jquery.js">
</script>
<link href=
"https://maxcdn.bootstrapcdn.com/bootstrap/3.3.6/css/bootstrap.min.css"
rel="stylesheet" >
<script src=
"https://maxcdn.bootstrapcdn.com/bootstrap/3.3.6/js/bootstrap.min.js">
</script>
<script src=
"https://cdnjs.cloudflare.com/ajax/libs/bootstrap-multiselect/0.9.13/js/bootstrap-multiselect.js">
</script>
<link href=
"https://cdnjs.cloudflare.com/ajax/libs/bootstrap-multiselect/0.9.13/css/bootstrap-multiselect.css"
rel="stylesheet">
<style>
.container
{
margin-top: 30px;
color: green;
font-size: 20px;
}
</style>
</head>
<body>
<br>
<p class="container"><b>GeeksforGeeks</b></p>
<div class="container">
<b>Select your choice:</b>
<select id="checkboxes" multiple="multiple">
<option value="Linked list">Linked list</option>
<option value="Array">Array</option>
<option value="Strings">Strings</option>
<option value="Stack">Stack</option>
<option value="Queue">Queue</option>
<option value="Graph">Graph</option>
<option value="Tree">Tree</option>
<option value="Maps">Maps</option>
</select>
</div>
<script>
$(document).ready(function() {
$('#checkboxes').multiselect();
});
</script>
</body>
</html>
Output: Now, as you can see in the output, a multi-select dropdown list is created where the client can choose multiple alternatives at once, by utilizing the multiple select plugins, integrated by following the above steps.
supported browser:
- Google Chrome
- Microsoft Edge
- Firefox
- Opera
- Safari
Similar Reads
jQuery multiple elements Selector The jQuery multiple elements Selector is used to select multiple elements of an HTML document. Syntax: $("element1, element2, element3, ...")Parameter: element: This parameter is required to specify the elements to be selected.Example 1: In this example, we will select the multiple elements by using
1 min read
jQuery bootstrapSelect Plugin In this article, we will learn how to implement the Bootstrap dropdown feature using jQuery bootstrapSelect plugin.Note: Please download the jQuery bootstrapSelect plugin in the working folder and include the required files in the head section of your HTML code.<link href=âhttps://fonts.googleapi
4 min read
How to Customize Bootstrap jQuery Plugins ? Bootstrap is a popular HTML, CSS, and JavaScript framework for building responsive, mobile-first web applications. It includes a library of jQuery plugins that provide various UI components and behaviors, such as modals, tabs, and carousels. While these plugins are useful out of the box, you may nee
4 min read
jQuery Mobile Selectmenu initSelector Option jQuery Mobile is a web-based technology used to make responsive content that can be accessed on all smartphones, tablets, and desktops. In this article, we will be using the jQuery Mobile Selectmenu initSelector option. The value of this option is a selector string that picks elements on the basis o
2 min read
How to select/deselect multiple options in dropdown using jQuery ? To select and deselect multiple options in a drop-down menu, we will use the HTML and CSS codes. HTML code helps to define the basic structure of the webpage and CSS will benefit in designing the web page. Some essential properties used in the code are as follows- <div> - This is a division ta
4 min read