So like i wrote in the title, i have multiple elements with same class i fetch that class and try to check for the child image’s width/height/src of that image.
i only manage to get the height // width of the first image however i get the src of all images.
here is the html:
<a class="test">
<img src="http://www.kitchenspro.com/files/Testimonials/Large/1502046700250312a71707.jpg">
</a>
<a class="test">
<img src="http://www.kitchenspro.com/files/Testimonials/Large/40183.9461166782.jpg">
</a>
<a class="test">
<img src="http://sphotos-a.xx.fbcdn.net/hphotos-ash4/s480x480/391362_365319466870994_1543740404_n.jpg">
</a>
here is the jquery
var imagesrc= "";
var imageheight = "";
var imagewidth = "";
var i=0;
$(".test > img").each(function() {
i++;
imagesrc = $(this).attr("src");
imageheight = $(this).width();
imagewidth = $(this).height();
document.write("<br>This is image's src: " + imagesrc + " This is img height: " + imageheight + " this is width: " + imagewidth + "<br>");
});
I apologize if i didnt present the code the right way.
Any help would be highly appreciated.
Thanks in advanced.
Exactly what @Musa said.
To help clean up your code and give a lesson on efficiency and native javascript, I have supplied a snippet.