简体   繁体   English

如何使幻灯片淡入淡出?

[英]How can I make my slideshow fade?

Im trying to edit my current javascript file to make my image slideshow fade into each other rather than jumping from picture to picture. 我正在尝试编辑当前的javascript文件,以使图像幻灯片放映彼此淡化,而不是逐张跳转。 Here is my current code: 这是我当前的代码:

var MyImage=document.getElementById("myPhoto");

var imageArray=["workone.jpg", "worktwo.jpg", "workthree.jpg"]

var imageIndex=0;

function changeImage () {
myPhoto.setAttribute("src", imageArray [ imageIndex]);
imageIndex++;
if (imageIndex>=imageArray.length) {
    imageIndex=0;
}
}

var intervalHandle = setInterval(changeImage,4000);

myPhoto.onclick=function() {
clearInterval(intervalHandle);
}    

You can use some jQuery here. 您可以在此处使用一些jQuery。 Check the fadeIn and fadeOut functions. 检查fadeInfadeOut功能。 You can also achieve this with raw javascript by changing the element's opacity gradually. 您也可以通过逐渐更改元素的不透明度来使用原始javascript实现此目的。

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM