jQueruy execution is not complete : i have a jquery code which replace some html attributes value 

 

    for (i = 0; i < 3; i++) {
    						
    						$("."+i+"-div").attr('data-thumb', image_array[i]);
    					    $("."+i+"-a").attr('href', image_array[i]);
    					    $("."+i+"-img").attr('src', image_array[i]);
    					}

Actually this code is working but it is slow .

 for example if iake the page then most of the time data-thumb & href are replaced correctly but still the image  src is not changed .

 But when i refresh the page then img src also changing .

 How to solve this ?