JSFiddle - React, Tailwind, and code Playground

by Graham Fairweather

HTML

<select id='select'>
  <option value='one' selected=true>One</option>
  <option value='two'>Two</option>
  <option value='three'>Three</option>
</select>
<button id="reset">Reset</div>

JavaScript

document.getElementById("reset").addEventListener("click", function () {
    var select = document.getElementById("select"),
        option = select.options.item(0);
    
    while (option)  {
        if (option.defaultSelected) {
            select.selectedIndex = option.index;
            break;
        }
    
        option = option.nextElementSibling;
    }
}, false);