【发布时间】:2019-07-24 08:43:00
【问题描述】:
在选择第1个下拉列表时,在第二个下拉列表中删除select“已禁用”属性。
我尝试了一些解决方案,但没有解决我的问题。我尝试过的解决方案如下:
1)$('#xyz').prop("disabled", false);
2)$("#xyz").attr('disabled', true).trigger("liszt:updated");
分享我的代码如下:
HTML
//This is 2nd Dropdown
<select id="xyz" class="selectpicker form-control" multiple title="-- Select --" disabled>
<option value="" disabled>-- Select --</option>
<option value="A">A</option>
<option value="B">B</option>
</select>
JS
$("#1stdropdown").change(function() { //This is 1st Dropdown
if ($("#1stdropdown").val() == "") {
$("#btnSubmit").attr('disabled', true);
$("#xyz").append($("<option>",{value: "",text: "-- Select --"}));
}
else {
$("#btnSubmit").attr('disabled', false);
$("#xyz").removeAttr("disabled").prop("disabled", false); // I am stuck here
}
});
【问题讨论】:
标签: jquery bootstrap-selectpicker