Create Clone Without Effecting Results of Original Object
- by user1655096
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');
});