Answers for "how to get selected option value in select2"

0

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');

  });
});
Posted by: Guest on March-16-2021
1

select2 find option by value

$('#Select2ID option[value="actualVal"]).text()
Posted by: Guest on September-17-2021

Code answers related to "how to get selected option value in select2"

Code answers related to "Javascript"

Browse Popular Code Answers by Language