Wednesday, 01 Nov, 2023 -456

How to clear select2 selected value in js

Clearing the selected value in select2 using JavaScript

The code in JSFiddle can be used with a remote data source and still allow for clearing a Select2 input. One solution is to set the select2 option to blank HTML. Another solution is to retrieve the saved value from the array and clear it. According to the documentation, it is also possible to clear the input by setting the value to an empty string. One example of this implementation is provided in the elaboration.


How to clear select2 dropdown?

Solution 1:

$("#exam_type_id").val('').trigger("change");

Tags
Most Popular
img
How to install WordPress
02 Apr, 2024 view: 2008
img
Xampp Tutorial Create Your Own Local Test Server
02 Apr, 2024 view: 1037
img
How to Install Laravel
02 Apr, 2024 view: 868
img
PHP is not recognized as an internal or external command
02 Apr, 2024 view: 659
img
How to Install Composer on Windows
01 Apr, 2024 view: 652
img
Summernote image upload
01 Nov, 2023 view: 596
img
How to clear select2 selected value in js
01 Nov, 2023 view: 456
img
Zipping and Unzipping Files in Linux
02 Apr, 2024 view: 401
img
How to add Datepicker in Bootstrap
26 Apr, 2024 view: 398
img
How to Import a MySQL Database using Command Line
02 Apr, 2024 view: 385
img
How to Installation Laragon
01 Apr, 2024 view: 235
img
How to Installing an SSL certificate on your server using cPanel
06 Apr, 2024 view: 210
img
Paypal Payment Gateway Integration With Laravel
06 Apr, 2024 view: 175
img
How to Use Laravel Middleware to Protect Your Application
09 Apr, 2024 view: 170
img
Laravel Cache Clear Command Php Artisan Optimize
09 Apr, 2024 view: 168
img
Laravel Authentication Tutorial
09 Apr, 2024 view: 158
img
laravel qr code generator package
18 Apr, 2024 view: 158
img
How to Integrate Stripe Payment in Laravel
06 Apr, 2024 view: 157
img
why important website development learn
10 Apr, 2024 view: 155
Trending