How can I execute the onchange event handler on select when I change the option?
document.getElementById('selct').value=2;
<select id="selct" onchange="alert('change success')">
<option value="0">val1</option>
<option value="1">val2</option>
<option value="2">val3</option>
<option value="3">val4</option>
<option value="4">val5</option>
<option value="5">val6</option>
</select>
When I do that, the result is val3
, but select's onchange
didn't work.
How can I fix it?