如何制作替换的图像fadeIn()



我一直在玩一个脚本,它将图像从低质量版本替换为高质量版本,替换工作正常,但是,我需要被替换的图像慢慢淡入,而不是像现在这样立即被替换。

//For each of the images in the class
$(".image-to-be-reloaded").each(function (i, classReturn) {
    var image = classReturn.firstChild; //Gets the image for that element

    //Get the original source
    var originalSource = image.src;
    //Replaces the preview within the query string to use the high quality version.
    var finishedSource = //My replace method goes here
    image.src = finishedSource; //Update the image src

    $(classReturn).replaceWith(image).fadeIn(10000);
});

我正在使用的fadeIn没有被执行,尽管前面的文本肯定是,我在这里做错了什么?

我已经找到了一种方法来实现我试图使用以下代码段所做的事情。

$(classReturn).replaceWith(function () {
    return $(image).hide().fadeIn(4000);
});

最新更新