来自:jquery多选择依赖的选项 [英] From: jquery multiple select option dependent

查看:134
本文介绍了来自:jquery多选择依赖的选项的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我知道如何设置jquery,这样如果选择了一个select选项,那么另一个select中的选项可以被禁用:例如

I know how to setup jquery so that if one select option is chosen, then options within another select can be disabled: e.g.

$("#div1").change(function(){  
if ($(this).val() == "100" ) {
$("#div2 option[value='200']").attr('disabled','disabled');
});

但是我无法将它带到下一个阶段,因此如果选择1>选项1和选择2>选项3选择那么select3应该禁用某些选项。

but I am having trouble taking this to the next stage so that if Select1>option1 AND Select2>option 3 are chosen THEN select3 should disable certain options.

推荐答案

您需要实现两个.change那些你检查当前选择的值和另一个的值

You'll need to implement two .change() functions and in each of those you check the value of the current select AND the value of the other one

$('#div1').change(function() {
   if($(this).val() == "100" && $('#div2').val() == "200") {
      ...
   }
});

$('#div2').change(function() {
   if($(this).val() == "200" && $('#div1').val() == "100") {
      ...
   }
});

这篇关于来自:jquery多选择依赖的选项的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆