Horje
select2 set value jquery Code Example
select2 clear options
Remove the selected options : 
-----------------------------
$('#mySelect2').val(null).trigger('change');

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

Completly remove the select2 initialization :
--------------------------------------------
$('#payment_method').html('').select2({data: [{id: '', text: ''}]});
jquery select2 set value
<select id="lang" >
   <option value="1">php</option>
   <option value="2">asp</option>
   <option value="3">java</option>
</select>

<script>
	$("#lang").select2().select2('val','1');
</script>
select2 tags set value jquery
$('#mySelect').select2({
  data: ['one','two'],
  tags: true
});
$('#mySelect').val(['one','two']).trigger('change')
Select options of Select2 control based on values using Jquery
$('#mySelect2').val('1'); // Select the option with a value of '1'
$('#mySelect2').trigger('change'); // Notify any JS components that the value changed
Source: select2.org
select2 set value jquery
$('#inputID').select2('data', {id: 100, a_key: 'Lorem Ipsum'});
select2 set value jquery
$('#all_contacts').select2('data', {id: '123', text: 'res_data.primary_email'});




Javascript

Related
JSX expression with JS template literals Code Example JSX expression with JS template literals Code Example
table sort datatable Code Example table sort datatable Code Example
why is necessary to run react-native run Code Example why is necessary to run react-native run Code Example
Public properties can be created via Static public fields Code Example Public properties can be created via Static public fields Code Example
mysql timestamp to time/days  ago function Code Example mysql timestamp to time/days ago function Code Example

Type:
Code Example
Category:
Coding
Sub Category:
Code Example
Uploaded by:
Admin
Views:
9