【发布时间】:2021-04-13 08:52:07
【问题描述】:
我想要一种在鼠标悬停时将 PNG 更改为动画 GIF 的方法,如下所示:
鼠标悬停在 PNG 图像上 => 8 秒加载第一个动画。暂停 4 秒并加载下一个动画 暂停 4 秒并加载最后一个。
我的代码如下
<img id="mylogo" src="images/unicorn-logo-white.png"/>
<script>
function chnageGif(){
$('#mylogo').attr("src", "images/Looped Pooping Rainbow CU Logo + Text.gif");
}
$(function() {
$("#mylogo").hover(
function() {
setTimeout(chnageGif, 8000);
$(this).attr("src", "images/Loop Dance CU Logo + Text.gif");
},
function() {
$(this).attr("src", "images/unicorn-logo-white.png");
}
);
});
现在我只能在8秒后更改一次图像,我需要再更改一次4秒
【问题讨论】:
标签: javascript html jquery css frontend