HTML img 属性“完整" [英] HTML img attribute "complete"
本文介绍了HTML img 属性“完整"的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!
问题描述
谁能解释一下属性complete
的含义?
Can anyone explain the meaning of the attribute complete
?
我在某处读到它可能与 DOM 有关.
I read somewhere that it might have to do with DOM.
<img src="/folder/pic.jpeg" complete="complete" />
推荐答案
当图片下载完成时设置.
It's set when the image has been downloaded.
我从来没有像你的例子那样在 HTML 中明确地看到它 (MDN 说它不是 img
元素的属性).我只是用来检查图像是否已使用 JavaScript 下载(但是存在跨浏览器问题).HTMLImageElement
上的属性返回一个 Boolean
.
I've never seen it explicitly in the HTML like in your example (MDN says it's not an attribute for a img
element) . I just use to check if the image has been downloaded with JavaScript (there are cross browser issues with that, however). The property on a HTMLImageElement
returns a Boolean
.
[].forEach.call(document.querySelector("img"), function(img) {
// Loaded?
img.complete && (img.style.border = "5px solid #f00");
});
这篇关于HTML img 属性“完整"的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!
查看全文