Wednesday, 01 Nov, 2023 -1655

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
02 Apr, 2024 view: 3785
img
02 Apr, 2024 view: 2538
img
01 Apr, 2024 view: 2435
img
01 Nov, 2023 view: 2250
img
26 Apr, 2024 view: 1526
img
02 Apr, 2024 view: 1462
img
01 Apr, 2024 view: 1344
img
18 Apr, 2024 view: 1255
img
09 Apr, 2024 view: 1242
img
10 Apr, 2024 view: 1159
img
26 Feb, 2025 view: 1097
img
16 Mar, 2025 view: 1006
Trending