How to Jquery each complete
The promise()
method is usually for AJAX, but it can be used with each()
to achieve what you want:
$('.element').each(function (key, val) {
console.log('Do something to each individual .element');
}).promise().done(function () {
console.log('Did things to every .element, all done.');
});
To execute code after the each
loop is over :
var count = $("element").length;
$("element").each(function (i) {
// loop
if (i+1 === count) {
// this will be executed at the end of the loop
}
});