JSFiddle - React, Tailwind, and code Playground

by mohammadAdil

HTML

<select name="select-2" id="select-2">
        <option value="1">1</option>
        <option value="2" selected>2</option>
        <option value="3">3</option>
    </select>

JavaScript

$(function () {
    $('#select-2').change(ShowSelected);
    $('#select-2').triggerHandler("change");
    function ShowSelected() {
            if ($(this).val() == 1) {
                console.log('value 1 is selected');
            } else if ($(this).val() == 2) {
                console.log('value 2 is selected');
            } else if ($(this).val() == 3) {
                console.log('value 3 is selected');
            }
    }

});