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












边栏推荐
- 通信网络基础知识01
- Leetcode Day5 delete duplicate email
- [网络]跨区域网络的通信学习IPv4地址的分类和计算
- 党员故事|李青艾用漫画带动农民增收致富
- 克服“看牙恐惧”,我们用技术改变行业
- 美国将提供250亿美元补贴,鼓励英特尔等芯片制造商迁回产线
- MySQL8 Status Variables: Internal Temporary Tables and Files
- Integration and implementation of login click graphic verification code in personal blog system
- This customized keyboard turns me on~
- High beam software has obtained Alibaba cloud product ecological integration certification, and is working with Alibaba cloud to build new cooperation
猜你喜欢

App自动化测试是怎么实现H5测试的

通信网络基础知识01

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

Business visualization - let your flowchart "run" (4. Actual business scenario test)

Question bank and answers of the latest national fire-fighting facility operators (intermediate fire-fighting facility operators) in 2022

基于C语言的信息管理系统和小游戏

Edge detection and connection of image segmentation realized by MATLAB

时间转日期的sql语句应该怎么写?

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

How does app automated testing achieve H5 testing
随机推荐
Salt SSH of saltstack
Leetcode Day1 score ranking
China's first chip stamp released: built-in 120um ultra-thin NFC chip
leetcode day1 分数排名
Android section 13 03xutils detailed explanation of database framework (addition, deletion and modification)
CDGA|工业互联网行业怎么做好数据治理?
Know small and medium LAN WLAN
Design of air combat game based on qtgui image interface
数字滤波器设计——Matlab
芯片功耗性能验证:从困境到超越
调用整数或字符数组函数里的参数应该传入啥
Nokia expands its 5g agreement with BT and will become its largest wireless access device supplier
Test Development Notes
基于MATLAB的函数拟合
开盘暴涨215%!国产信号链芯片企业芯海科技登陆科创板
你知道雨的类型有几种?
MySQL8 tmp_table_size和max_heap_table_size
How to write the SQL statement of time to date?
English Translation Spanish - batch English Translation Spanish tools free of charge
KPMG China: insights into information technology audit projects of securities fund management institutions