with on click event i returned the below drop down element as ajax json response, without page refresh:
<select class='custom-select col-md-4' id='family'>
<option value''> Select family</option>
<option value='1'>familyName</option>
</select>
then I want to execute a function when changed the option using:
$('#family').on('change', function(){
alert("Yeey");
});
but doesn’t seem to be working.
2
Answers
Your code seems to be working.
Just add one more option in select
For now, you have only one option which is by default selected so no change event applied.
your script is good.
example:
Needs more than 1 option.
By default, the first option is selected.
So there’s no on change event triggering.