Q:
Jquery.each() stops looping at last item
I am having an issue where the each loop won't loop through all of the elements on the page.
My HTML:
My Jquery:
var myimages = $(".thumbnail-images img");
$(myimages).each(function(i){
var images = $(this).attr("src");
images = images.split("?").pop();
var prefix = myimages.eq(i).attr("src");
myimages.eq(i).attr("src", prefix + "?" + images);
});
So, it grabs all the images in the HTML, but it only loops through 4 of them. It will skip over the last 3 images in the class="thumbnail-images"
Any idea why this isn't looping through the whole image list?
A:
You are overwriting the i var in the scope of the.each() function, you need to use i outside of the function:
var myimages = $(".thumbnail-images img");
var i = 0;
$(myimages).each(function(i){
var images = $(this).attr("src");
images = images.split("?").pop();
var prefix = myimages.eq(i).attr("src");
myimages.eq(i).attr("src", prefix + "?" + images);
});
Early high-dose cyclophosphamide and total body irradiation in steroid-refractory graft-versus-host disease.
Although total body be359ba680
Related links:
Comments