How to use callbacks on jQuery each function?
I am trying something like:
$.each(images, function(key, value) {
new_images+= '<li><a href="'+value+'"><img src="'+value+'" alt="'+[key]+'" /></a></li>';
}, function (){
$('#Gallery').remove();
$('body').append('<ul class="gallery">'+new_images+'</ul>');
});
$.each();
is a synchronous function. That means you don't need a callback function inside because any code you write after $.each();
will run affter $.each();
ends.