select values on select2 code example
Example 1: how to set value select2
$('#sel_users').select2().trigger('change');
$(document).ready(function(){
// Initialize Select2
$('#sel_users').select2();
// Set option selected onchange
$('#user_selected').change(function(){
var value = $(this).val();
// Set selected
$('#sel_users').val(value);
$('#sel_users').select2().trigger('change');
});
});
Example 2: select2
$(".js-example-basic-multiple-limit").select2({
maximumSelectionLength: 3
});