function initCountryCodes(dropdown_el, default_country) { const sg = { call_code: '65', name: 'Singapore' }; setTimeout(function() { if ($(dropdown_el).hasClass('select2-hidden-accessible')) { $(dropdown_el).select2('destroy'); } $(dropdown_el).find('option').remove(); var sgOption = new Option('+' + sg.call_code, sg.call_code, true, true); $(dropdown_el).append(sgOption); if ($(dropdown_el).hasClass('select2-hidden-accessible')) { $(dropdown_el).select2(); } $(dropdown_el).trigger('change'); }, 100); } $(async function () { initCountryCodes('#signup-countrycode', 'SG'); initCountryCodes('#login-countrycode', 'SG'); });