国产一级a片免费看高清,亚洲熟女中文字幕在线视频,黄三级高清在线播放,免费黄色视频在线看
打開APP
未登錄
開通VIP,暢享免費(fèi)電子書等14項超值服
開通VIP
首頁
好書
留言交流
下載APP
聯(lián)系客服
jQuery實(shí)現(xiàn)頁面滾動圖片按需加載(轉(zhuǎn)載)
WindySky
>《前端技術(shù)》
2017.12.01
關(guān)注
[html]
view plain
copy
print
?
<!doctype html>
<html lang="en">
<head>
<meta charset="UTF-8">
<title>jquery scrolling</title>
<link rel="stylesheet" href="css/style.css"/>
</head>
<body>
<!--imgbox-->
<div class="wrapper">
<div class="img-box">
<img src="img/1.png" />
</div>
<div class="img-box">
<img src="img/2.png" />
</div>
<div class="img-box">
<img src="img/3.png" />
</div>
<div class="img-box">
<img data-url="img/4.png" src="img/pix.png" />
</div>
<div class="img-box">
<img data-url="img/5.png" src="img/pix.png" />
</div>
<div class="img-box">
<img data-url="img/6.png" src="img/pix.png" />
</div>
<div class="img-box">
<img data-url="img/7.png" src="img/pix.png" />
</div>
<div class="img-box">
<img data-url="img/8.png" src="img/pix.png" />
</div>
<div class="img-box">
<img data-url="img/9.png" src="img/pix.png" />
</div>
<div class="img-box">
<img data-url="img/10.png" src="img/pix.png" />
</div>
<div class="img-box">
<img data-url="img/11.png" src="img/pix.png" />
</div>
<div class="img-box">
<img data-url="img/12.png" src="img/pix.png" />
</div>
<div class="img-box">
<img data-url="img/13.png" src="img/pix.png" />
</div>
<div class="img-box">
<img data-url="img/14.png" src="img/pix.png" />
</div>
<div class="img-box">
<img data-url="img/15.png" src="img/pix.png" />
</div>
<div class="img-box">
<img data-url="img/16.png" src="img/pix.png" />
</div>
<div class="img-box">
<img data-url="img/17.png" src="img/pix.png" />
</div>
<div class="img-box">
<img data-url="img/18.png" src="img/pix.png" />
</div>
<div class="img-box">
<img data-url="img/19.png" src="img/pix.png" />
</div>
<div class="img-box">
<img data-url="img/20.png" src="img/pix.png" />
</div>
</div>
<script src="js/jquery_1.9.js"></script>
<script src="js/main.js"></script>
</body>
</html>
[css]
view plain
copy
print
?
*{
margin: 0;
padding: 0;
}
/*wrapper*/
.wrapper{
width: 500px;
height: 5000px;
margin: auto;
}
.img-box{
width: 100%;
margin-bottom: 20px;
padding-bottom: 10px;
height: 260px;
text-align: center;
border-bottom: 2px dashed #ccc;
}
[javascript]
view plain
copy
print
?
$(function(){
var $wd = $(window),
$img = $('img'),
imgTop, //圖片距離頂部高度
scTop, //滾動條高度
wH; //窗口高度
wH = $wd.height(); //獲得可視瀏覽器的高度
$wd.scroll( function() {
scTop = $wd.scrollTop(); //獲取滾動條到頂部的垂直高度
$img.each(function(){
imgTop = $(this).offset().top;
if(imgTop - wH < scTop && //圖片必須出現(xiàn)在窗口底部上面
imgTop - wH > 0 && //排除首頁圖片
$(this).attr('src') != $(this).data('url')){ //排除已經(jīng)加載過的圖片
$(this).attr({
src: $(this).data('url')
});
}
});
});
});
原文鏈接:https://my.oschina.net/leipeng/blog/221911
本站僅提供存儲服務(wù),所有內(nèi)容均由用戶發(fā)布,如發(fā)現(xiàn)有害或侵權(quán)內(nèi)容,請
點(diǎn)擊舉報
。
打開APP,閱讀全文并永久保存
查看更多類似文章
猜你喜歡
類似文章
超酷的翻書效果jquery代碼
jquery moblie磁貼作風(fēng)九宮格
jQuery---固定導(dǎo)航欄案例
基于HTML/CSS/JS微信公眾號展示頁面模板
jQuery篩選列表過濾插件Filterizr
在ecshop中實(shí)現(xiàn)商品詳細(xì)頁面的放大鏡功能
更多類似文章 >>
生活服務(wù)
首頁
萬象
文化
人生
生活
健康
教育
職場
理財
娛樂
藝術(shù)
上網(wǎng)
留言交流
回頂部
聯(lián)系我們
分享
收藏
點(diǎn)擊這里,查看已保存的文章
導(dǎo)長圖
關(guān)注
一鍵復(fù)制
下載文章
綁定賬號成功
后續(xù)可登錄賬號暢享VIP特權(quán)!
如果VIP功能使用有故障,
可點(diǎn)擊這里聯(lián)系客服!
聯(lián)系客服
微信登錄中...
請勿關(guān)閉此頁面
先別劃走!
送你5元優(yōu)惠券,購買VIP限時立減!
5
元
優(yōu)惠券
優(yōu)惠券還有
10:00
過期
馬上使用
×