两个自定义多选下拉列表相互依赖,并根据组合结果需要显示项目,当选择一项时,如果未找到组合,则应禁用其他下拉列表值
<div class="firstdrop">
<span value="ss">ss</span>
<span value="dd">dd</span>
</div>
<div class="seconddrop">
<span value="game">game</span>
<span value="football">football</span>
</div>
<div class="game ss"></div>
<div class="gamee dd"></div>
<div class="football ss"></div>
<div class="ss"></div>
答案 0 :(得分:0)
我过去做过这种方式(基于你的例子):
if($('#firstdrop').val() == 'some value') {
var oldval = $('#seconddrop').val(); // In case the chosen option exists in the new option set
var opts = '<option value="val1">Val 1</option>';
opts += '<option value="val2">Val 2</option>';
etc...
$('#seconddrop').empty().append(opts).val(oldval);
}
哦,你需要使用select标签,而不是div。
<select multiple id="firstdrop">...
<select multiple id="seconddrop">...