Basic Jquery question Can't get function to Trigger on Load
Have a select drop down with an ID country. This function works fine when the user selects the country from the drop down however I cant seem to get it to Trigger on load. am using Jquery 1.32 if this is useful? thanks for your help.
- $("#country").bind("load change", function () {
var val = $(this).val();
switch(val){
case 'USA':
$(".stateinput").hide();
$(".territorydropdown").hide();
$(".statedropdown").show();
$(".stateinput input").attr({name: 'countystate_hidden', id:
'countystate_hidden'});
$(".territorydropdown select").attr({name: 'countystate_hidden', id:
'countystate_hidden'});
$(".statedropdown select").attr({name: 'countystate', id:
'countystate'}).addClass("required");
break;
case 'CAN':
$(".stateinput").hide();
$(".statedropdown").hide();
$(".territorydropdown").show();
$(".stateinput input").attr({name: 'countystate_hidden', id:
'countystate_hidden'});
$(".statedropdown select").attr({name: 'countystate_hidden', id:
'countystate_hidden'})
$(".territorydropdown select").attr({name: 'countystate', id:
'countystate'}).addClass("required");
break;
default:
$(".statedropdown").hide();
$(".territorydropdown").hide();
$(".stateinput").show();
$(".statedropdown select").attr({name: 'countystate_hidden', id:
'countystate_hidden'}).removeClass("required");
$(".territorydropdown select").attr({name: 'countystate_hidden', id:
'countystate_hidden'});
$(".stateinput input").attr({name: 'countystate', id: 'countystate'});
break;
}
});