标签:
<img data-src="/path/to/image.jpg" >
img {
opacity: 1;
transition: opacity 0.3s;
}
img[data-src] {
opacity: 0;
}
[].forEach.call(document.querySelectorAll(‘img[data-src]‘), function(img) {
img.setAttribute(‘src‘, img.getAttribute(‘data-src‘));
img.onload = function() {
img.removeAttribute(‘data-src‘);
};
});
标签:
原文地址:http://www.cnblogs.com/jayruan/p/5406502.html