I've a question related to a select element and jquery. I currently have a change event so the changeShippingForm function gets called when the select element value has been changed, this is working just fine.
But I also want the change event fired at onload. How can I achieve this?
$(document).ready(function() {
$('#shippingType').change(changeShippingForm);
});
function changeShippingForm() {
// do some stuff
}
use .trigger()
help.
$(document).ready(function() {
$('#shippingType').change(changeShippingForm).trigger('change');
});
or even shorter, use the shortcut:
$(document).ready(function() {
$('#shippingType').change(changeShippingForm).change();
});
If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With