jQuery remove SELECT options based on another SELECT selected (Need support for all browsers)

前端 未结 5 937
粉色の甜心
粉色の甜心 2020-12-05 16:11

Say I have this dropdown:


  
  
  

then do this:

$(function() {
    var allOptions = $('#theOptions2 option').clone();
    $('#theOptions1').change(function() {
        var val = $(this).val();
        $('#theOptions2').html(allOptions.filter('.option-' + val));
    });
});

提交回复
热议问题