Tuesday, December 4, 2012

javascript – Jquery does not quite work inside for loop

I have following code inside javascript:



for (var i=0; i < images_array.length; i++) {
$(\'#thumb_\'+ i).live(\'click\', function(){
$(\'#image_container_\' + current_image_index).hide();
current_image_index = i;
alert(current_image_index);
$(\'#image_container_\' + current_image_index).show();
});}


when I click on any thumb, i get images_array.length value. Does anyone know what is happenning?






Rating: 3 out of 5 based on 3 ratings



The post javascript – Jquery does not quite work inside for loop appeared first on Javascript ASK.






via Javascript ASK http://javascriptask.phpfogapp.com/javascript-jquery-does-not-quite-work-inside-for-loop.html

No comments:

Post a Comment