淡入几秒钟后更改图像

时间:2018-10-23 03:40:44

标签: settimeout fadein

我还是一个新手,所以花了我一段时间才能得到我需要的东西,即使它看起来很简单。我找到了一些东西并对其进行了更改,以适应我的需要,但似乎无法添加淡入效果。

var timerid = 0;
var images = new Array( "../wp-content/uploads/2017/06/18920213_415373625516573_4599602564023401118_n.png",
"../wp-content/uploads/2018/10/junta7.jpg",
"../wp-content/uploads/2018/10/projetoluzeamor.jpg");
var countimages = 0;
function startTime()
{

    var tDate = new Date();

    if(countimages == images.length)
    {
        countimages = 0;
    }

    document.getElementById("img").src = images[countimages];

    countimages++;

    timerid = setTimeout("startTime()", 2000);
}

效果很好,但是每次更改显示图像时我都希望有淡入效果。我不知道fadeIn()应该去哪里。

0 个答案:

没有答案