Select2 is very famous jquery plugin for HTML Select-control. Select2 also supports multi-value select boxes. Select2 is very easy to use and configurable.
Select2 provides you a customizable select box with support for searching, tagging, remote data sets, infinite scrolling, and many other highly used options.
Also, check out other tutorials of select2,
$("#selectId").select2();
as u can see, I have used select2()
method on HTML dropdown which id is #selectId
.
I will tell you how to select all elements of the multi-select box onClick() of a particular option, ie. if you have the option ‘all’ in a multi-select box and you need to select all elements of multi-select when the user select 'All'
option.
The following code needs to use select all options of the multi-select box,
$('#selectId > option').prop("selected",true);
Also trigger a change event if you want to reflect the changes on the interface too.
$('#selectId > option').prop("selected",true).trigger("change");
You can also clear all selected options.
$('#selectId > option').prop("selected",false).trigger("change");
This tutorial helps integrate a PHP SDK with Laravel. We'll install aws-php-sdk into laravel application and access all aws services… Read More
in this quick PHP tutorial, We'll discuss php_eol with examples. PHP_EOL is a predefined constant in PHP and represents an… Read More
This Laravel tutorial helps to understand table Relationships using Elequonte ORM. We'll explore laravel table Relationships usage and best practices… Read More
We'll explore different join methods of Laravel eloquent with examples. The join helps to fetch the data from multiple database… Read More
in this Laravel tutorial, We'll explore valet, which is a development environment for macOS minimalists. It's a lightweight Laravel development… Read More
I'll go through how to use soft delete in Laravel 10 in this post. The soft deletes are a method… Read More
View Comments
Thanks mate your post was really useful!