I'm using Office UI Fabric and I'm using a ms-Dropdown control. From javascript, I'm trying to select and item
<div class="ms-Dropdown" tabindex="0">
<label class="ms-Label" style="font-size: 14px; font-weight: 600;">My Options</label>
<i class="ms-Dropdown-caretDown ms-Icon ms-Icon--ChevronDown"></i>
<select id="myoptions" class="ms-Dropdown-select">
<option>Choose an option&hellip;</option>
<option>One</option>
<option>Two</option>
</select>
</div>
From Javascript, I run
document.getElementById("myoptions").value = "Two";
or
document.getElementById("myoptions").selectedIndex = 2;
Both don't work properly. The UI don't refresh with the new selected option.
Any idea how can I select an item from Javascript (no jQuery)?
document.getElementById("myoptions").selectedIndex = 2;should work!!!