我想获得this effect在我的网页上工作。无法读取属性'完整'null - 完成
但我已经尝试过多次,每次都失败。所以,这就是为什么我要先在地方一级尝试它的原因。我复制了您在codepen.io网页上看到的所有内容,并将两张图片替换为我的图片。此外,我添加了id id="coverart"
img和多数民众赞成它。
但我得到一个错误在此:
if (image.complete) {
它的原因是:
无法读取属性空
的 '完整' 但是,如果我键入此在我的控制台中:
document.getElementById('coverart');
我得到的元素回:
<img id="coverart" src="https://gamekeys-shop.de/wp-content/uploads/2017/01/coverart.png">
因此,它不能为空...可能是什么原因呢,我怎么能解决这个问题? Here you can download the little html, css and js files.
编辑:
如果插入alert(image)
,你会得到空。如果这个
image.onload = start;
替换此
if (image.complete) {
start();
} else {
image.onload = start;
}
你会得到相同的错误无效...为什么我得到空......它不能为空?
@hsnbl'图像。完成“返回图像是否已经完全加载。如果有,它返回'true' –
@TobiasGlaus感谢您的信息:) – hasan
@Erik你尝试使用$(document).ready(function(){//你的代码在这里)) – hasan