Answers for "clear the options on select"

6

select2 clear options

Remove the selected options : 
-----------------------------
$('#mySelect2').val(null).trigger('change');

============================================

Completly remove the select2 initialization :
--------------------------------------------
$('#payment_method').html('').select2({data: [{id: '', text: ''}]});
Posted by: Guest on July-30-2020
1

jquery select clear options

$('#mySelect')
    .find('option')
    .remove()
    .end()
    .append('<option value="whatever">text</option>')
    .val('whatever')
;
Posted by: Guest on April-15-2021

Code answers related to "clear the options on select"

Code answers related to "Javascript"

Browse Popular Code Answers by Language