两个 bootstrap-select 联动, JQuery代码如下,然后选择第一个选择框几次之后,出现了联动选择框不能选择的现象,隐藏的源select并没有问题
$("#SearchBrand").change(function() {
var brandId = $("#SearchBrand").val();
var select = $("#SearchSeries");
var optgroup = select.find("optgroup");
select.val(-1);
if (brandId !== '-1') {
var optgroupSelect = select.find("optgroup[brand='" + brandId + "']");
$(optgroup).attr("disabled", "disabled");
$(optgroupSelect).removeAttr("disabled");
var options = $(optgroupSelect).find("option");
options.removeAttr("disabled");
}
else{
$(optgroup).attr("disabled", "disabled");
}
select.selectpicker('refresh');
});
使用attr导致的问题!