This solution:
$('#payment_method').on('hidden.bs.select', function (e) {
You get the sample length, so it can be useful in a loop
console.log(e.target.selectedOptions.length);
and you can also scroll through the selected values:
$.each( e.target.selectedOptions , function( index, obj ){ console.log(obj.value); });
source share