JSFiddle - React, Tailwind, and code Playground
by darkajax
HTML
<select id='s'>
<option value='0'>select</option>
<option value='1'>ok</option>
<option value='2'>no</option>
<option value='nice'>nice!</option>
</select>
<input id='i' type='hidden' />
<button type='button' id='b'>go</button>
JavaScript
$("#b").click(function(){
//should output: [user selection] - []
alert("[" + $("#s").val() + "] - [" + $("#i").val() + "]");
$("#i").val('nice');
//should output: [user selection] - [nice]
alert("[" + $("#s").val() + "] - [" + $("#i").val() + "]");
//should output: [nice] - [nice]
$("#s").val($("#i").val());
alert("[" + $("#s").val() + "] - [" + $("#i").val() + "]");
});