remove & add select box option if other selection changes

后端 未结 3 942
夕颜
夕颜 2021-01-26 10:12

I have 3 select boxes and all are having same value (clones) & created on change of reference table selection. now i want to manage the selection on the three Constraint d

3条回答
  •  余生分开走
    2021-01-26 10:44

    If I understand you correctly, you have elements with the same value in each elements when one of the elements is selected. Here's a small snippet showing how I did that:

    HTML

    
    
    
    

    jQuery

    $(document).ready(function () {
        $('select.hello').change(function () {
            $('select.hello option').attr('disabled', false);
            $('select.hello').each(function() {
                var val = $(this).find('option:selected').val();
                if (!val) return;
                $('select.hello option').filter(function() {
                    return $(this).val() == val;
                }).attr('disabled', 'disabled');
            });
        });
    });
    

    And here is a link to the jsFiddle: http://jsfiddle.net/yLCVf/1/

提交回复
热议问题