On change event for country code in intlTelInput

I am trying to set onchange event in intlTelInput (jQuery). But it’s not working . If I change country code then it will listen as change . Here is my code. It’s working when I change mobile number. But I want it when I change country code. Thanks in advance.

<input type="text" name="user_phone_number" id="user_phone_number"> 

$('input[name=user_phone_number]').change(function() {
     var countryCode = $("#user_phone_number").intlTelInput("getSelectedCountryData").dialCode;
     alert(countryCode);
            
 });

Answer

check the documentation, you can use

input.addEventListener("countrychange", function() {
  // do something with iti.getSelectedCountryData()
});

and try this solution also

var input = $("#user_phone_number");
input.intlTelInput();

input.on("countrychange", function() {
  input.val('')
});