jQuery - disable/enable select options

后端 未结 1 1767
清歌不尽
清歌不尽 2020-12-16 15:48

I need some help with jquery if condition. I\'ve been searching and testing for hours, any help would be great !!! I get this HTML code:

1条回答
  •  囚心锁ツ
    2020-12-16 16:09

    try this:

    $(function(){
        $("input").change(function(){
            if ( $(this).val() < 3 ) {
                $('#select2').prop('disabled', true);
                $('#select1').on("change",function() {
                    $('#select2').val($(this).val());
                });
            }else {
                $("#select1").off();
                $('#select1, #select2').prop('disabled', false);
            }
        });
    });
    

    Demo:http://jsfiddle.net/qhPp7/2/

    0 讨论(0)
提交回复
热议问题