let $theImage = $('img[data-src]').first()
let 图片上边缘距离页面顶部的距离 = $theImage.offset().top
$(window).on('scroll', function (e) {
let top = window.scrollY
if (top + $(window).height() >= 图片上边缘距离页面顶部的距离) {
$theImage[0].src = $theImage[0].getAttribute('data-src')
} else {
console.log('还没到')
}
})
网友评论