Create Clone Without Effecting Results of Original Object
        Posted  
        
            by 
                user1655096
            
        on Stack Overflow
        
        See other posts from Stack Overflow
        
            or by user1655096
        
        
        
        Published on 2012-09-07T15:32:40Z
        Indexed on 
            2012/09/07
            15:38 UTC
        
        
        Read the original article
        Hit count: 273
        
I have a function that when selecting an option, returns results. I want to be able to clone that function and have the ability to return another set of results, without adding the new results to the original object.
// shows / hides results based on selection
     $(".categories-select").live("change" ,function(){
        if($(this).val() == 'red'){ 
          $('.red').removeClass('hide');
           // toggles red results, sub menus
          $(this).parent('.controls').find('.sub').removeClass('hide');
        }
        if($(this).val() == 'blue'){ 
          $('.blue').removeClass('hide');
          $(this).parent('.controls').find('.sub').addClass('hide');
        }
        if($(this).val() == 'purple'){ 
          $('.purple').removeClass('hide');
          $(this).parent('.controls').find('.sub').addClass('hide');
        }
        if($(this).val() == 'orange'){ 
          $('.orange').removeClass('hide');
          $(this).parent('.controls').find('.sub').addClass('hide');
        }
      });
     // Duplicates category select menu 
    $(".add-color").find(function(){
      $(".color-category").clone().removeClass('color-category').appendTo("#we-want-to").find('.sub,').addClass('hide') ;
    });
     $(".add-color-alternate").click(function(){
      $(".color-category-alternate").clone().removeClass('color-category-alternate').appendTo("#we-want-to").find('.sub, .results-table').addClass('hide');
    });
© Stack Overflow or respective owner