<!DOCTYPE html>
<html lang="en">
<head>
<meta charset="UTF-8">
<title>Title</title>
</head>
<style>
.wrap{
width: 200px;
height: 200px;
background: #ff6600;
position: absolute;
left: 50%;
top: 50%;
margin-top: -100px;
margin-left: -100px;
}
</style>
<script>
window.onload=function () {
var textNode=document.querySelector(".wrap");
//火狐
if (textNode.addEventListener){
textNode.addEventListener("DOMMouseScroll",function () {
console.log("火狐滚");
})
}
//非火狐浏览器
textNode.onmousewheel=function () {
console.log("我再滚");
}
}
</script>
<body>
<div class="wrap">
</div>
</body>
</html>
滚轮兼容
最新推荐文章于 2022-07-11 17:20:30 发布