Javascript 查找选项选择不在chrome中显示
当我在第一次选择中选择城市时,我想在第二次选择中显示具体的州。 下一个代码在firefox中工作,但在chrome中不显示状态选项 我想我需要更改Javascript 查找选项选择不在chrome中显示,javascript,google-chrome,Javascript,Google Chrome,当我在第一次选择中选择城市时,我想在第二次选择中显示具体的州。 下一个代码在firefox中工作,但在chrome中不显示状态选项 我想我需要更改city.find(“option[value=“+self+”]”)。show()但是什么 var city = jQuery("#city"); jQuery("#state").on("change", function () { var self = jQuery(this).val(); if (
city.find(“option[value=“+self+”]”)。show()代码>但是什么
var city = jQuery("#city");
jQuery("#state").on("change", function () {
var self = jQuery(this).val();
if (jQuery("#state").val() == "0") {
jQuery(".city").hide();
} else {
jQuery(".city").show();
}
city.find("option").hide();
city.find("option[value=" + self + "]").show();
city.find("option[value=" + 0 + "]").prop("selected", true);
}).change();
您可以用引号将值括起来'
:
city.find("option[value='" + self + "']").show();
// -------------------- ^ and here ^ ---------