How to have an anim gif on a link and play it on hover and reset

That can be achieved by use a static image and your gif image(Hey, that how 9gag do it!)

A basic script could be somthing like that:

<img id="myImg" src="staticImg.png" />

<script>
    $(function() {
        $("#myImg").hover(
            function() {
                $(this).attr("src", "animatedImg.gif");
            },
            function() {
                $(this).attr("src", "staticImg.jpg");
            }                         
        );                  
    });
</script>

Leave a Comment