tft每日頭條

 > 圖文

 > 最簡單的鼠标滾動事件

最簡單的鼠标滾動事件

圖文 更新时间:2025-11-15 03:49:58

最簡單的鼠标滾動事件(鼠标滾輪的滾動事件)1

// 鼠标滾動事件 windowAddMouseWheel() { let that = this; var scrollFunc = function (e) { e = e || window.event; if (e.wheelDelta) { //判斷浏覽器IE,谷歌滑輪事件 if (e.wheelDelta > 0) { //當滑輪向上滾動時 console.log("向上滾動") }else if(e.wheelDelta < 0){ console.log("向下滾動") } } else if (e.detail) { //Firefox滑輪事件 if (e.detail > 0) { //當滑輪向上滾動時 console.log("向上滾動") }else if (e.detail < 0) { //當滑輪向下滾動時 console.log("向下滾動") } } }; //給頁面綁定滑輪滾動事件 if (document.addEventListener) { //火狐使用DOMMouseScroll綁定 document.addEventListener("DOMMouseScroll", scrollFunc, false); } //其他浏覽器直接綁定滾動事件 window.onmousewheel = document.onmousewheel = scrollFunc; },

沒了,結束了,是不是很簡單呐,如有錯誤,歡迎留言.如有問題,不吝賜教。如果此篇博文對您有幫助,還請動動小手點贊 收藏 ⭐留言 呐~,謝謝 ~ ~

,

更多精彩资讯请关注tft每日頭條,我们将持续为您更新最新资讯!

查看全部

相关圖文资讯推荐

热门圖文资讯推荐

网友关注

Copyright 2023-2025 - www.tftnews.com All Rights Reserved