select2 select option using jquery code example

Example 1: select2 clear options

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

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

Completly remove the select2 initialization :
--------------------------------------------
$('#payment_method').html('').select2({data: [{id: '', text: ''}]});

Example 2: select2 dropdown with option to add new item

$('#select2')
    .select2()
    .on('select2:open', () => {
        $(".select2-results:not(:has(a))").append('<a href="#" style="padding: 6px;height: 20px;display: inline-table;">Create new item</a>');
})

Example 3: jquery select2

//Select2 is a jQuery based replacement for select boxes. It supports searching, remote data sets, and infinite scrolling of results.