Using Jquery ,
I have an array result
[<a href=""><img src="image1"></a>,<a href=""><img src="image2"></a>]
if I try to do each I only get the first one in array ,
how could I split this so I could do
$.each(my_array, function (index, value) {
this.parent().attr.('href',this.src);// assign image as href to parent
});
here is bad try
Please note that array above is returned to my by imagesLoaded plugin for jquery and I canot select parent directly since it is not within the result , ZI must go by element.parent()
any help is appreciated. thnx!
Given the following HTML:
<a href=""><img src="image1"></a><a href=""><img src="image2"></a>And a jQuery selector which catches only these elements, in this case simply:
You would do:
Example
If your selector is on the
imgtags:You would do:
Example