JSFiddle - React, Tailwind, and code Playground

HTML

<select id="meSelect">
</select>
<select id="meSelect2">
</select>

JavaScript

appendOptions("meSelect", "value1", "text1");
appendOptions("meSelect2", "value2", "text2");
        
alert($("#mySelect option").length);
alert($("#meSelect2 option").length);

function appendOptions(selId, val, txt)
{
    var sel = $("#"+selId)[0], options=sel.options;
    options[options.length] = new Option(val,txt);
}

function appendOptions2(selId, val, txt)
{
    var opt = document.createElement('option');
    opt.text = txt;
    opt.value = val;
    var sel = document.getElementById(selId);

    try {
        sel.add(opt, null); // standards compliant; doesn't work in IE
    }catch(ex){
                sel.add(opt); // IE only
    }
}