Onclick play GIF image with jQuery and start from beginning

后端 未结 2 1500
我在风中等你
我在风中等你 2021-01-06 10:52

I have a website with images on it. Some of the images are animated GIF images. What I\'ve done is to show a static image of the GIF and on a click event, the actual GIF ima

相关标签:
2条回答
  • 2021-01-06 11:28

    this would be a solution to larger images Restart an animated GIF from JavaScript without reloading the image

    in a nut shell load the image into a javascript variable then change out the src on click

    $(function(){
        var image = new Image();
           image.src='http://rack.3.mshcdn.com/media/ZgkyMDEyLzEwLzE5LzExXzMzXzMzXzE3Nl9maWxlCnAJdGh1bWIJMTIwMHg    5NjAwPg/462b8072';
         $('#img').click(function(){
           $(this).attr('src',image.src);
         }); 
     });
    

    http://jsfiddle.net/GS427/1/

    its ugly i couldnt find the right image for the starting but you can see that it starts in the same place every time

    0 讨论(0)
  • 2021-01-06 11:34

    You need to divide mouse event to mousedown and mouseup, perform hiding first and showing second or viceversa on mousedown then perform hiding first and showing second or viceversa on up,

    0 讨论(0)
提交回复
热议问题