Select2 Get selected option data
you can use this
$("#e2 option:selected").text();
This work for me:
On simple select2 to get label value:
$('#myVar').select2('data')[0].<name_label_from_data_input>
May be helpful do an data dump from select2 variable:
$('#myVar').on('change', function (evt) {
if ($('#myVar').select2('val') != null){
console.log($('#myVar').select2('data')[0]);
}
});
And catch your the label's name attribute.
Good luck!
Try this:
$('#e2').select2('data')
return selected option data