【发布时间】:2022-01-11 12:41:06
【问题描述】:
考虑以下引导选择选择器:
<select id="parent" class="selectpicker">
<option value="1">Parent 1</option>
<option value="2">Parent 2</option>
</select>
<select id="child" class="selectpicker">
<option value="1">Child - Parent 1</option>
<option value="2">Child - Parent 2</option>
</select>
$("#parent").on('change', function (e) {
var parentId = $(this).val();
$("#child option").each((i,a) => {
var childParentId = $(a).value();
if(childParentId != parentId) {
$(a).hide();
} else { $(a).show() }
});
$("#child").selectpicker("refresh")
});
无论我做什么, $(a).show() 都没有效果。 我错过了什么?
【问题讨论】:
标签: jquery bootstrap-4 jquery-selectors