Reputation: 121
I have below jquery code, this calls when COUNTRY dropdown value get changed, but i need to call this event when i set the value to country dropdown, is there any way to call this piece of code explicitly?
//set the change event for the country.
$( "#COUNTRY" ).change(
function() {
alert("in country change");
// code to change the other dropdown values based on country
});
Upvotes: 0
Views: 1696
Reputation: 148180
You can call with chagne()
and use trigger("change")
on the dropdown (select)
$("#COUNTRY").change();
OR
$("#COUNTRY").trigger("change");
Upvotes: 2
Reputation: 82251
You need to use .trigger()
or .change()
:
$('#COUNTRY').trigger('change');
or
$('#COUNTRY').change();
Upvotes: 3
Reputation: 25537
Use trigger in jquery to explicitly call an event
$( "#COUNTRY" ).trigger("change");
Upvotes: 1