JSFiddle - React, Tailwind, and code Playground
by Matt Ball
HTML
<select id="mySelect">
<option value="volvo">Volvo</option>
<option value="saab">Saab</option>
<option value="mercedes">Mercedes</option>
<option value="audi">Audi</option>
</select>
JavaScript
var mySelect = document.getElementById('mySelect'),
newOption = document.createElement('option');
newOption.value = 'bmw';
// FF does not support innerText, have to handle that separately
if (typeof newOption.innerText === 'undefined')
{
newOption.textContent = 'BMW';
}
else
{
newOption.innerText = 'BMW';
}
mySelect.appendChild(newOption);