当前位置:网站首页>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 停止传播












边栏推荐
- Adobe XD web design tutorial
- Application of time series database in cigarette factory
- [physical application] Wake induced dynamic simulation of underwater floating wind turbine wind field with matlab code
- Srs4.0 installation steps
- 服务器正文21:不同编译器对预编译的处理(简单介绍msvc和gcc)
- CVPR19 - 调参干货《Bag of Tricks for Image Classification with Convolutional Neural Network》
- 软件测试开发基础|测开中的几个工具开发实战
- Learn from Li Mu, deep learning - linear regression and basic optimization function
- R语言与数据分析实战11-数据的删除
- pytest 自定义HOOK函数
猜你喜欢

3、 Uni app fixed or direct to a certain page

Module 8 of the construction camp

Application of time series database in monitoring operation and maintenance platform

使用Xilinx MIG验证硬件DDR设计

6-20 vulnerability exploitation proftpd test

BM16 delete duplicate elements in the ordered linked list -ii

vim学习手册
![[machine learning] support vector machine classification](/img/6d/e4fb9b5bf82362edcebbf366f9b73e.png)
[machine learning] support vector machine classification

Leetcode skimming - super power 372 medium

4、 Interface requests data to update input information interactively
随机推荐
CVPR19 - 调参干货《Bag of Tricks for Image Classification with Convolutional Neural Network》
IMU 加热
Learn from Li Mu in depth -softmax return
【图像分割】基于方向谷形检测实现静脉纹路分割附MATLAB代码
From Bayesian filter to Kalman filter (2)
Streamlit machine learning application development tutorial
From Bayesian filter to Kalman filter (zero)
【数据分析】基于MATLAB实现SVDD决策边界可视化
Image processing web application development tutorial
DevCon.exe 导出output至指定文件
用于异常检测的Transformer - InTra《Inpainting Transformer for Anomaly Detection》
About ASM redundancy
Application of time series database in monitoring operation and maintenance platform
When unity customizes the editor, let the subclass inherit the inspector display effect of the parent class
GPIO port configuration of K60
QT running image
sudo rosdep init 出现 ERROR: cannot download default
TSDB and blockchain
JDBC简单封装
QT user defined control user guide (flying Qingyun)