-
Latest Chinese 中文 topics – The freeCodeCamp Forum查看全部
-
window.onload=function(){}//window.onload事件當文檔加載完后開始獲取元素
聲明變量獲取元素時:
在var中, document.getElementById('')獲取元素ID
? ? ? ? ? ? ? ? ?.getElementsTagName('')獲取標簽元素,注意獲取標簽元素時Element后面多一個s
添加事件綁定:(觸發事件要做什么)
? ? 點擊箭頭next時,進行圖片位置偏移,即改變圖片的left值
? ? next.onclick = function(){
? ? ? ? list.style.left = parseInt(list.style.left) + 偏移參數 + 'px';
}
? ? 封裝為函數:把正、負參數通過函數調用
? ? function jiantou(canshu){
? ? ? ? list.style.left = parseInt(list.style.left) + canshu + 'px';
}
? ? next.onclick=function(){
? ? ? ? jiantou(-canshu)//輸入一個負的偏移參數
}
? ? prev.onclick=function(){
? ? ? ? jiantou(+canshu)//輸入一個正的偏移參數
}
查看全部 -
oo查看全部
-
無縫滾動 輪播圖 放大鏡 購物車 鼠標拖拽 狂亂小球 頂部和側邊導航條查看全部
-
setTimeout()的用法。
查看全部
舉報