I have a button , which when clicked resets the dropdown menu to its default option.
I have a onchange event listener for the drop down menu. The event listener is not getting triggered when I click the button.
HTML CODE
<select id="my_select">
<option value="a">a</option>
<option value="b">b</option>
<option value="c">c</option>
</select>
<div id="reset">reset</div>
$("#reset").on("click", function () {
document.getElementById('my_select').selectedIndex = 0;
});
$("#my_select").change(function(){
alert("Hi");
});
The above on change code is not triggering when x is clicked, whereas it is getting triggered when manually changed. I expect it to work for document.getElementById('Typess').selectedIndex = 1; as well. How to make this work ?