Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

Do setting selected value of a select box trigger change event of the select list?

I am setting the selected value of a select list as below

$("#typeFilter").val("0");

My question is do making this, triggers $("#typeFilter").change event?

like image 217
Kuttan Sujith Avatar asked Dec 04 '25 10:12

Kuttan Sujith


1 Answers

No it won't trigger the change event if you want to trigger the event after setting the value use trigger. Change event is triggered only if it is an interaction from device not with javascript.

$("#typeFilter").val("0");
$("#typeFilter").trigger('change');

Sample Demo

like image 137
PSL Avatar answered Dec 07 '25 00:12

PSL



Donate For Us

If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!