Clone elements, append them into array, $.map through array and append to NEW element
by lasha
JavaScript
var browseCharitiesMobileContent = [];
$('.charityContent').each(function(i, el) {
browseCharitiesMobileContent.push($('#' + $(el).attr('id')));
// console.log(browseCharitiesMobileContent);
});
$.map(browseCharitiesMobileContent, function(val, i) {
var $contentToAdd = val.clone();
$contentToAdd.attr('id', function(i, val) {
return val + '-mobile';
}).appendTo('#browseCharitiesMobile');
});
$('#browseCharitiesMobile').find('.view-all-link').remove();
$('#select-charity-cause').change(function(e) {
var $currentCharityItem = $(this).val();
$('#browseCharitiesMobile .charityContent').hide();
$('#' + $currentCharityItem).show();
});