var str = []; $('#countries div.dragableBoxRight').each(function() { str.push($(this).attr('id')+'='+$('div.dragableBox', this).attr('id')); }); str = str.join('&');