I can't find on select2 documentation a way to remove all the options in a select2 form. The old stckoverflow answers to this questions seem not to work since the new version (I'm using 4.0.3) has a different behavior
Asked
Active
Viewed 8,407 times
2 Answers
16
Just
$('#id').empty().trigger("change");
Where '#id' is the jQuery selector for your select2 element.
Ricardo Garcia Landete
- 387
- 3
- 11
-
Sorry, I sent it without finishing the last sentence. Is it ok now? – Ricardo Garcia Landete Dec 22 '17 at 12:36
-
Sorry … don't seems to work on 4.1.0-RC1 maybe an RC issue – Denis Chenu May 23 '22 at 16:40
0
Previous answer will delete all values, but in the official documentation it says:
$("#id").val(null).trigger("change");
greatgumz
- 408
- 3
- 17