How to trigger jQuery change event in code
Use the trigger() method
$(selector).trigger("change");
For me
$('#element').val('...').change()
is the best way.
Note:
.change()
is deprecated in newer versions use.trigger('change')
instead.
The parameterless form of the change() method triggers a change
event. You can write something like:
$(document).ready(function() {
$("#yourInitialElementID").change(function() {
// Do something here...
$(".yourDropDownClass").change();
});
});
$(selector).change()
.change()
.trigger("change")
Longer slower alternative, better for abstraction.
.trigger("change")
$(selector).trigger("change")