-3
$('.chide').each(function(index) {
        setTimeout(function(el) {
        el.animate({opacity:0});
       }, index * 200, $(this));
 });

I want to run another function after completed above function how can I do that please help..

iplus26
  • 2,518
  • 15
  • 26
  • use [callbacks](https://developer.mozilla.org/en-US/docs/Mozilla/js-ctypes/Using_js-ctypes/Declaring_and_Using_Callbacks) – iplus26 Aug 03 '15 at 07:43

2 Answers2

0

i think this was you can achieve your solution here

$('.chide').each(function(index) {
        setTimeout(function(el) {
        el.animate({
          opacity:0,
          complete: function(){
                       alert('call your another function here you can write here with return as well can create a function here aswell you can just call the function here that is created ');
                    } 
        });
       }, index * 200, $(this));
 })

here i have created example with working code using only divs

$(document).ready(function(){
    $('div').each(function(index) {
       console.log(index);
       $(this).animate({
          opacity:1,
          height: "toggle",          
       }, index * 2200,function(){
         $(this).show();
       });       
    })
})
div{
 width : 100px;
 height: 100px;
 border: 2px solid grey;
}
<div>

 </div>
 <div>
  
 </div>
 <div>
  
 </div>
 <div>
  
 </div>
 <div>
  
 </div>
Himesh Aadeshara
  • 2,114
  • 16
  • 26
0

If your app/site can use modern features use Promises.

Promise.all(arrayOfPromises).then(function(arrayOfResults) {
  //...
});

Its sane way of organizing your code, some solid polyfills are available: http://www.html5rocks.com/en/tutorials/es6/promises/

Mircea
  • 11,373
  • 26
  • 64
  • 95