在悬停时动画 gif [英] Animating a gif on hover

查看:31
本文介绍了在悬停时动画 gif的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我为此寻找了答案并找到了它,但我不知道如何使用它.

I've looked for the answer for this and I found it, but I don't know how to use it.

停止加载 gif 动画,鼠标悬停时开始激活

Guffa 对这个问题的回答正是我想要的,但我不知道如何使用该代码.

Guffa's answer to that question is exactly what I want, but I don't know how to use that code.

我有 jquery 插件,但是我应该把代码放在哪里(不是插件;Guffa 的答案中的代码)?我如何使用它来参考图像?有没有我必须调用的函数才能让它工作?如果是这样,最好的称呼是什么?

I have the jquery plugin, but where do I put the code (not the plugin; the code that was in Guffa's answer)? How do I use it in reference to the images? Is there a function I have to call to get it to work? If so, what would be the best way to call it?

很抱歉问了一个已经有人回答的问题,但他的回答不够具体,我无法评论以要求他提供更具体的答案.

Sorry for asking a question that has already been answered, but his answer wasn't specific enough and I couldn't comment to ask him for a more specific answer.

推荐答案

这里是您需要的工作示例 - http://jsfiddle.net/EXNZr/1/

Here is a working example for what you need - http://jsfiddle.net/EXNZr/1/

<img id="imgDino" src="http://bestuff.com/images/images_of_stuff/64x64crop/t-rex-51807.jpg?1176587870" />

<script>
    $(function() {
        $("#imgDino").hover(
            function() {
                $(this).attr("src", "animated.gif");
            },
            function() {
                $(this).attr("src", "static.gif");
            }                         
        );                  
    });
</script>

这篇关于在悬停时动画 gif的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆