我有一个定制的加载栏。我通过将他隐藏在照片的后面来使用它,所以每当照片发生变化时,背景就会出现,当照片加载时,加载栏就会隐藏在照片后面。最近,我不得不使用传输图像,现在在图像后面可以看到加载栏。
照片的id是“生成的”,这是css。
#generated {
border: 1px solid #021a40;
cursor: pointer;
background: url(../images/loading400px.gif) 50% no-repeat;
}
我有一个更改此图像的JS函数。
function AsynchronouslyDownloadImage(address, img) {
img.src = "static/images/shader.svg";
let downloadingImage = new Image();
downloadingImage.onload = function () {
// This img.style.background is what I thought will make my background disappear but this isn't working
img.style.background = "";
img.src = this.src;
};
downloadingImage.src = imagesEndpoint;
}
根据长长的评论,我认为ïmg.style.background是可以工作的。img是对其id=generated所引用的元素的引用。
https://stackoverflow.com/questions/51804499
复制相似问题