How to hide html form select option?

后端 未结 4 1071
萌比男神i
萌比男神i 2021-01-24 01:43

I have a very simple form which I would like to hide select options when another select field refines it.

Currently I have tried dispay: none as an inline s

4条回答
  •  一个人的身影
    2021-01-24 02:17

    In the end I used jquery clone, which seemed to do the trick.

    http://jsfiddle.net/3vPgY/10/

    var everything = $('#everything').clone(true);
    
    $('#refine').change(function () {
    
        var selectColour = $('option:selected', this).val().replace(/ /g, "-");
    
        if (refine != 0) {
    
            var everythingRefined = everything.clone(true).find('.default,.'+selectColour);
    
            $('#everything').removeAttr('disabled');
            $('#everything').empty().append(everythingRefined);
    
        } else {
    
            $('#everything').attr('disabled', 'disabled');
    
        }
    
    });
    

提交回复
热议问题