当前位置:网站首页>JS preventdefault() keyboard input limit onmousewheel stoppropagation stop event propagation
JS preventdefault() keyboard input limit onmousewheel stoppropagation stop event propagation
2022-07-28 19:54:00 【HandsomeDanielWu】
prevent prevent



Input limit 
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;
// to box Add mouse wheel event monitoring to the box
oBox.onmousewheel = function (e){
// Block default events , That is, when the user scrolls the mouse wheel in the box , The scrollbar scrolling of the page will not be triggered
e.preventDefault();
if(e.deltaY > 0){
a++;
}else{
a--;
}
oInfo.innerText = a;
}
</script>
</body> stopPropagation Stop spreading 












边栏推荐
- “中国网事·感动2022”二季度网络感动人物评选结果揭晓
- CDGA|工业互联网行业怎么做好数据治理?
- Huawei shares in Nanjing core vision, laying out the solid-state laser radar chip field
- How navicate modifies the database name
- Left alignment function of Lua language (handwriting)
- MATLAB实现的图像分割之边缘检测和连接
- redis 主从架构(sizeof函数怎么计算)
- leetcode day5 删除重复的电子邮箱
- MySQL8 Encrypting InnoDB Tablespaces
- NetCoreAPI操作Excel表格
猜你喜欢

11、 学习MySQL UNION 操作符

Use Hal Library of STM32 to drive 1.54 inch TFT screen (240*240 st7789v)

How openocd directly downloads programs to STM32 board through stlink (solved)

Oracle insert数据时字符串中有‘单引号问题

调用整数或字符数组函数里的参数应该传入啥

利用STM32的HAL库驱动1.54寸 TFT屏(240*240 ST7789V)

云计算笔记part.1——系统管理

High beam software has obtained Alibaba cloud product ecological integration certification, and is working with Alibaba cloud to build new cooperation

彻底理解位运算——与(&)、非(~)、或(|)、异或(^)

个人博克系统登录点击图形验证码的集成与实现
随机推荐
App自动化测试是怎么实现H5测试的
Leetcode day3 employees who exceed the manager's income
Idea properties file display \u solution of not displaying Chinese
MySQL8 Status Variables: Internal Temporary Tables and Files
[experience] some suggestions and experience on repairing electronic equipment
NPM installing and uninstalling global packages
美国将提供250亿美元补贴,鼓励英特尔等芯片制造商迁回产线
MySQL performance testing tool sysbench learning
English translation Italian - batch English translation Italian tools free of charge
MySQL8 tmp_ table_ Size and Max_ heap_ table_ size
Netcoreapi operation excel table
软考中级(系统集成项目管理工程师)高频考点
There is a 'single quotation mark' problem in the string when Oracle inserts data
Thoroughly understand bit operations -- and (&), not (~), or (|), XOR (^)
leetcode day3 超过经理收入的员工
亚马逊推出Amazon One手掌支付系统,非接触式掌静脉识别市场有望爆发
Leetcode Day5 delete duplicate email
leetcode day3 查找重复的电子邮箱
Android-第十三节03xUtils-数据库框架(增删改查)详解
云计算笔记part.2——应用管理