sree
sree

Reputation: 121

Call explicitly jquery change event

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

Answers (4)

Adil
Adil

Reputation: 148180

You can call with chagne() and use trigger("change") on the dropdown (select)

$("#COUNTRY").change();

OR

$("#COUNTRY").trigger("change");

Upvotes: 2

Milind Anantwar
Milind Anantwar

Reputation: 82251

You need to use .trigger() or .change():

 $('#COUNTRY').trigger('change');

or

 $('#COUNTRY').change();

Upvotes: 3

user2422457
user2422457

Reputation:

$( "#COUNTRY" ).trigger('change')

Upvotes: 1

Anoop Joshi P
Anoop Joshi P

Reputation: 25537

Use trigger in jquery to explicitly call an event

$( "#COUNTRY" ).trigger("change");

Upvotes: 1

Related Questions