Search Results

Search found 1 results on 1 pages for 'user1143357'.

Page 1/1 | 1 

  • jQuery variable iteration with .each()

    - by user1143357
    My code needs to capture the 'src' of an image in a variable. It then needs to insert this variable into a 'href' tag on a link which surrounds the image. My code is as follows: $('.fancybox-image-li img').each(function(test) { var test = $(this).attr("src"); $('.fancybox-image-link').attr('href', ''+test+''); }); Unfortunately what seems to be happening is the 'test' var is only getting the attribute of the last img and then inserting this into all the 'href' attributes. Any ideas how I can get the variable to change per image. Cheers!

    Read the article

1