JSFiddle - React, Tailwind, and code Playground

by grammar

HTML

<select></select>

JavaScript

$(function() {

    var $select = $('select'),
        optionsOne = ["foo", "bar"],
        optionsTwo = ["one", "two"]
    
    $select.on('change', function(e) {
        
        var $target = $(e.target),
            value = $target.val();
        
        if(value === "one") {
     		populateDropdown(optionsOne);
        } else if(value === "foo") {
           populateDropdown(optionsTwo);
        }
     
    });
    
    function populateDropdown(options) {
        $select.empty();
        for(var i = 0; i < options.length; i++) {
            $select.append($("<option value=" + options[i] + ">" + options[i] + "</option>"));
        }
        $select.trigger('click');
    }
    
    populateDropdown(optionsOne);
});