当前位置:网站首页>JS preventDefault() 键盘输入限制 onmousewheel stopPropagation停止事件传播
JS preventDefault() 键盘输入限制 onmousewheel stopPropagation停止事件传播
2022-07-28 17:28:00 【HandsomeDanielWu】
prevent阻止



输入限制
onmousewheel
<style>
#box{
width: 200px;
height: 200px;
background-color: #333;
padding-bottom: 20px;
}
body{
height: 2000px;
}
</style>
</head>
<body>
<div id="box">
</div>
<div id="info"></div>
<script>
var oBox = document.getElementById('box');
var oInfo = document.getElementById('info');
var a = 0;
// 给box盒子添加鼠标滚轮事件监听
oBox.onmousewheel = function (e){
// 阻止默认事件,就是说当用户在盒子里滚动鼠标滑轮的时候,不会触发页面的滚动条滚动
e.preventDefault();
if(e.deltaY > 0){
a++;
}else{
a--;
}
oInfo.innerText = a;
}
</script>
</body> stopPropagation 停止传播












边栏推荐
- It is the best tool to evaluate six kinds of map visualization software in three categories
- GPIO port configuration of K60
- Module 8 of the construction camp
- When unity customizes the editor, let the subclass inherit the inspector display effect of the parent class
- Application value of MES production management system to equipment
- 用于异常检测的Transformer - InTra《Inpainting Transformer for Anomaly Detection》
- MES生产管理系统对设备的应用价值
- 身份证号的奥秘
- Pointer learning of C language -- the consolidation of pointer knowledge and the relationship with functions, arrays and structures
- [machine learning] support vector machine classification
猜你喜欢

【物理应用】水下浮动风力涡轮机的尾流诱导动态模拟风场附matlab代码

6-20 vulnerability exploitation proftpd test

Photoshop responsive web design tutorial

MES生产管理系统对设备的应用价值

QT & OpenGL lighting

Libgdx learning road 02: draw game map with tiled

Application of time series database in bridge monitoring field

Learn from Li Mu in depth -softmax return

Application of TSDB in civil aircraft industry

Nips18(AD) - 利用几何增广的无监督异常检测《Deep Anomaly Detection Using Geometric Transformations》
随机推荐
C string to short[] method
When unity customizes the editor, let the subclass inherit the inspector display effect of the parent class
IMU 加热
Pytorch GPU yolov5 reports an error
ardupilot软件在环仿真与在线调试
Image processing web application development tutorial
ACM warm-up exercise 3 in 2022 summer vacation (detailed)
关于ASM冗余问题
Application of time series database in cigarette factory
Nips18(AD) - 利用几何增广的无监督异常检测《Deep Anomaly Detection Using Geometric Transformations》
VAE:变分自编码器的理解与实现
C language (high-level) character function and string function + Exercise
RFs self study notes (II): theoretical measurement model - without clutter but with detection probability
Application of time series database in monitoring operation and maintenance platform
vim学习手册
Qt: 一个SIGNAL绑定多个SLOT
Fantasy 5 (ue5) game engine complete course 2022
2022年暑假ACM热身练习3(详细)
VIM learning manual
ICLR21(classification) - 未来经典“ViT” 《AN IMAGE IS WORTH 16X16 WORDS》(含代码分析)