JSFiddle - React, Tailwind, and code Playground

HTML

<select multiple>
                <option name='baz' value='baz'>baz</option>
        <option name='foo' value='foo'>foo</option>
        <option name='bar' value='bar'>bar</option>
    </select>

<div id='out'></div>

JavaScript

$('select').change(function () {
    var selected_options = $(this).parent().find('option:selected');
    myFunction($.map(selected_options, function (selected_option) { return selected_option.value; }));
});

function myFunction(selectValues){
    console.log(selectValues)
    $.each(selectValues, function () {        
        var theitem = $('#' + this).html();
    });
}