JSFiddle - React, Tailwind, and code Playground
HTML
<select id="select">
<option value="foo">foo</option>
<option value="bar">bar</option>
<option value="baz">baz</option>
</select>
JavaScript
var index, option,
el = document.getElementById("select");
el.value = "bar";
log( "existent", el );
el.value = "qux";
log( "nonexistent", el );
function log( label, el ) {
var index = el.selectedIndex,
option = el.options[ index ];
console.log( label, {
"select value": el.value,
selectedIndex: index,
"option value": option && option.value
});
}