-
知識(shí)點(diǎn)查看全部
-
返回頂部查看全部
-
回到頂部主要知識(shí)點(diǎn)查看全部
-
知識(shí)點(diǎn)查看全部
-
知識(shí)點(diǎn)查看全部
-
主要知識(shí)點(diǎn)查看全部
-
錨鏈接查看全部
-
回到頂部查看全部
-
定時(shí)器查看全部
-
back-on-top主要知識(shí)點(diǎn)查看全部
-
任務(wù)1:獲取頁(yè)面可視區(qū)的高度代碼編寫 var clientHeiht = document.documentElement.clientHeiht; 任務(wù)2:獲取滾動(dòng)條距離頂部的高度 var osTop = document.documentElement.scrollTop document.body.scrollTop; 任務(wù)3:使用腳本控制“回到頂部”按鈕的顯示與隱藏 if (osTop >= clientHeight){ //顯示按鈕 obtn.style.display = 'block'; }else { //隱藏按鈕 obtn.style.display = 'none'; }查看全部
-
window是一個(gè)窗口類,onscroll是窗口類window的對(duì)象,滾動(dòng)滾動(dòng)條時(shí)觸發(fā)。查看全部
-
實(shí)現(xiàn)回到頂部效果主要知識(shí)點(diǎn): DOM操作: 1.document.getElementById:根據(jù)ID獲取標(biāo)簽元素 2.document.documentElement.scrollTop:滾動(dòng)條的數(shù)值,可讀寫 事件運(yùn)用: 1.window.onload:頁(yè)面加載完畢后觸發(fā) 2.onclick:點(diǎn)擊后觸發(fā) 3.window.onscroll:滾動(dòng)條滾動(dòng)時(shí)觸發(fā) 定時(shí)器: 1.setInterval():設(shè)置定時(shí)器,需傳2個(gè)參數(shù) 2.clearInterval():關(guān)閉定時(shí)器,需傳1個(gè)參數(shù)查看全部
-
錨鏈接: 優(yōu)點(diǎn):簡(jiǎn)單快速、沒(méi)有兼容性問(wèn)題 缺點(diǎn):視覺(jué)上不夠直觀,用戶體驗(yàn)不夠好查看全部
-
clientH=document.documentElement.clientHeightdocument.body.clientHeight; osTop=document.documentElement.scrollTopdocument.body.scrollTop;查看全部
舉報(bào)
0/150
提交
取消