I have a bunch of images on the page. I am trying to use jQuery to capture the height of each image and display it after the image. So here is my code:
$(document).ready(function() {
$(".thumb").each(function() {
imageWidth = $(".thumb img").attr("width");
$(this).after(imageWidth);
});
});
<div class="thumb"><img src="" border="0" class="thumb_img"></div>
<div class="thumb"><img src="" border="0" class="thumb_img"></div>
<div class="thumb"><img src="" border="0" class="thumb_img"></div>
[...]
code>
My jQuery logic is that I want to go through each "thumb" selector, assign the height img inside the "thumb" to the variable "imageWidth", and then display the height in the text after each thumb.
The problem I am facing is that it only works with the first image and then leaves. I can make it work if I use the thumb_img class, of course, but I need access to the image height for the thumb class.
, , jQuery. .
Chris