문제

My problem is when i try to Reload/Reset the Animated GIF so like that when you click over the static image it will play the animated image from the beginning like this:

$(this).parent().find('img.badge-item-animated-img').attr('src', src);

It is working but the action is occurring for all of the images that i have in my page.

How can i make it happen only for the one that I'm clicking?

도움이 되었습니까?

해결책

You are going up from current element, then looking within that parent for all the images.... you only want to find within the current element

Change to:

/* find within "this"*/
$(this).find('img.badge-item-animated-img').attr('src', src);

Edit: clcik on jpg, change src of GIF:

$('.badge-item-img').click(function(){
   $(this).parent().next().find('img.badge-item-animated-img').attr('src',function(i,src){
         /* replace src with same vale so GIF refreshes*/
         return src;
    });
})
라이센스 : CC-BY-SA ~와 함께 속성
제휴하지 않습니다 StackOverflow
scroll top