Hide/Show <select> depending on the other <select>

后端 未结 2 1478
天命终不由人
天命终不由人 2020-12-22 01:22

I have two ...

Listen to the change event on the countries array.

$("#countries").change(function() {
    // find the selected country
    var selectedCountry = $(this).val();
    // if US or Canada
    if(selectedCountry == "USA" || selectedCountry == "Canada") {
        // show the cities list
        $("#cities").show();
    }
    // otherwise hide it
    else {
        $("#cities").hide();
    }
});

提交回复
热议问题