I have 2
images that changes after a few seconds. I want to add a FadeIn/FadeOut
effect when these images changes.
<script>
var img_tracker = "icon1";
function changeImg()
{
var pic = document.getElementById("img1");
if (img_tracker == "icon1") {
pic.src = "images/icon1.png";
img_tracker = "icon2.png";
} else {
pic.src = "images/icon2.png";
img_tracker = "icon1";
}
}
setInterval("changeImg()", 2000);
</script>
<img src="images/icon1.png" id="img1">
That is my current code, is there any way I can add fadeOut/fadeIn
on every image change?
See Question&Answers more detail:
os 与恶龙缠斗过久,自身亦成为恶龙;凝视深渊过久,深渊将回以凝视…