动画悬停一个GIF [英] Animating a gif on hover
问题描述
我看过的答案,这和我找到了,但我不知道如何使用它。
I've looked for the answer for this and I found it, but I don't know how to use it.
<一个href=\"http://stackoverflow.com/questions/5818003/stop-a-gif-animation-onload-on-mouseover-start-the-activation?answertab=votes#tab-top\">Stop一个GIF动画onload事件,鼠标悬停启动激活
Guffa的回答这个问题正是我想要的,但我不知道如何使用code。
Guffa's answer to that question is exactly what I want, but I don't know how to use that code.
我有jQuery插件,但我在哪里把code(不是插件;在code,它是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屋!