jQuery - Call function once at end of each loop
Posted
by
user668499
on Stack Overflow
See other posts from Stack Overflow
or by user668499
Published on 2012-11-26T17:02:38Z
Indexed on
2012/11/26
17:03 UTC
Read the original article
Hit count: 134
How can I call a function once at the end of an each loop.
This alerts 'finished' on each loop, I want it once when the loop has finished.
$(function(){
var imgArr=[];
var lis = $('#gallery li')
lis.each(function(){
imgArr.push(this.outerHTML);
$(this).remove();
alertFun();
})
function alertFun(){
alert('finished');
}
})
© Stack Overflow or respective owner