更新时间:2023-11-26 11:16:28
另一种选择是通过在内存中创建图像元素来触发 onload
和/或 onerror
事件并将其 src
属性设置为原始图像的原始 src
属性.这是我的意思的一个例子:
Another option is to trigger the onload
and/or onerror
events by creating an in memory image element and setting its src
attribute to the original src
attribute of the original image. Here's an example of what I mean:
$("<img/>")
.on('load', function() { console.log("image loaded correctly"); })
.on('error', function() { console.log("error loading image"); })
.attr("src", $(originalImage).attr("src"))
;
希望这有帮助!