Jquery adding and removing items from listbox

后端 未结 9 1021
粉色の甜心
粉色の甜心 2021-02-03 13:13

I\'ve created this fiddle, it allows the user to click on either art or video, dynamically populating the the second listbox with the list associated with those selections. Ther

9条回答
  •  轮回少年
    2021-02-03 13:23

    Really Clean and Simple (works great and only a few lines):

            $("#icon_move_right").click(function(){
                $("#available_groups option:selected").each(function(){ 
                    available_group = $(this).val();
                    $("#assigned_groups").append("");
                });
                $("#available_groups option:selected").remove()
            });
    
            $("#icon_move_left").click(function(){
                $("#assigned_groups option:selected").each(function(){ 
                    assigned_group = $(this).val();
                    $("#available_groups").append("");
                });
                $("#assigned_groups option:selected").remove()
            });
    
            $("#icon_move_right_all").click(function(){
                $("#available_groups option").each(function(){ 
                    available_group = $(this).val();
                    $("#assigned_groups").append("");
                });
                $("#available_groups option").remove()
            });
    
            $("#icon_move_left_all").click(function(){
                $("#assigned_groups option").each(function(){ 
                    assigned_group = $(this).val();
                    $("#available_groups").append("");
                });
                $("#assigned_groups option").remove()
            });
    

提交回复
热议问题