Does attr substitute src have fadeIn effect at the same time?

the target of the substitute

<img class="" id="productview_icon" src="">

the object of initiating event

<img class="change-display" data-icon_src="xxx" src="">

event

e.preventDefault();
var icon_src = e.currentTarget.dataset.icon_src;

$("-sharpproductview_icon").fadeIn().attr("src", icon_src);

I found that I couldn"t achieve the fadeIn effect.
he just src it, but it doesn"t have any effect.
how to achieve this function?

Mar.23,2021

document: http://www.w3school.com.cn/jq. setting transition time


you can only use two images, one fadeIn, one fadeOut


use css to write two class to control, and then use js to switch class, to add fadeIn/fadeOut effect, or write animation. Use animate to control


Picture FadeIn Test

$(document).ready(function () {
        var img = $("-sharpmy-img");
        img.fadeOut("slow",function () {
            img.attr("src",img.data("src"));
            img.fadeIn(4000);
        });
    });
Menu