I have a .change() function set for a dropdown menu with an ID of #country. When the page loads, I'm trying to set the dropdown menu to "United States" and run the .change() function:
$('#country').change(function () { resetDisclosure(); var countryCode = $(this).val(); var countryName = $('#country option:selected').text(); $('#'+countryCode.toString()).fadeIn('slow'); if(countryCode == 'OC' || countryCode == 'EU') { $('#OC h4, #EU h4').html('For Residents of ' + countryName + ''); } $.fancybox.resize(); $.fancybox.center(); }); $("#country").val('OC'); $("#country").change();
The last function there is wrong, because I can't force the .change() on load. How can I go about forcing the change function?
I'm super beginner and have tried to assign the contents of the .change() function to a different function and call that, but it didn't work either.