JSFiddle - React, Tailwind, and code Playground

by kapry

HTML

<!doctype html>
<html lang="es">
<head>
    <meta charset="UTF-8">
    <title>Jquery multiselected</title>
    <!-- Jquery 3.2.1  -->
    <script src="https://code.jquery.com/jquery-3.2.1.min.js"></script>
    <script type="text/javascript">
        $(document).ready(function () {
            $('#miselect').change(function () {
                // Obtener valor del las opciones selecionadas
                var selectValue = $("#miselect").val() || [];
                $("#resultadoValue").text(selectValue);

                // Obtener el texto del las opciones selecionadas
                var selectText = $("#miselect option:selected").map(function () {
                    return $(this).text();
                }).get().join(',');
                $('#resultadoTexto').text(selectText);
            });
        })
    </script>
</head>
<body>
<select id="miselect" multiple="multiple">
    <option value = "1">Elemento 1</option>
    <option value = "2">Elemento 2</option>
    <option value = "3">Elemento 3</option>
    <option value = "4">Elemento 4</option>
</select>
<br>
<span id="resultadoValue">Valor</span>
<br>
<span id="resultadoTexto">Texto</span>
</body>
</html>