当前位置:网站首页>BOM DOM
BOM DOM
2022-07-02 09:43:00 【大海里没有水】
一、BOM
注意: window继承EventTarget
二、DOM
1、事件监听
2、事件流 - 事件冒泡 / 事件捕获
3、事件对象的属性和方法
const spanEL = document.querySelector(".span");
// 在回调这个函数的时候,会传递event参数
spanEL.addEventListener("click", function (event) {
console.log("span被点击", event);
console.log("事件的类型", event.type);
// 当发生点击和处理点击的元素不一样
console.log("事件的元素", event.target, event.currentTarget);
console.log("事件发生的位置", event.offsetX, event.offsetY);
});
// 常用的方法
// preventDefault, 防止默认行为
const aEl = document.querySelector("a")
aEl.addEventListener("click", (event) => {
event.preventDefault();
})
// stopPropagation ,可阻止事件捕获
边栏推荐
- CDA data analysis -- Introduction and use of aarrr growth model
- Calculate the maximum path sum of binary tree
- Fresh, 2022 advanced Android interview must know 100 questions (interview questions + answer analysis)
- From scratch, develop a web office suite (3): mouse events
- Le tutoriel F - String le plus facile à comprendre de l'histoire.
- Differences between nodes and sharding in ES cluster
- CDA data analysis -- common knowledge points induction of Excel data processing
- Thesis translation: 2022_ PACDNN: A phase-aware composite deep neural network for speech enhancement
- [C language] Yang Hui triangle, customize the number of lines of the triangle
- 上传文件时,服务器报错:IOFileUploadException: Processing of multipart/form-data request failed. 设备上没有空间
猜你喜欢
随机推荐
CPU指令集介绍
求16以内正整数的阶乘,也就是n的阶层(0=<n<=16)。输入1111退出。
Map和Set
Leetcode209 subarray with the smallest length
Performance tuning project case
(C语言)3个小代码:1+2+3+···+100=?和判断一个年份是闰年还是平年?和计算圆的周长和面积?
[I'm a mound pytorch tutorial] learning notes
Test shift left and right
SSH automatically disconnects (pretends to be dead) after a period of no operation
中国交通标志检测数据集
[geek challenge 2019] upload
初始JDBC 编程
AI中台技术调研
二分刷题记录(洛谷题单)区间的甄别
5g era, learning audio and video development, a super hot audio and video advanced development and learning classic
SCM power supply
CDA data analysis -- Introduction and use of aarrr growth model
Small guide for rapid formation of manipulator (VII): description method of position and posture of manipulator
Leetcode922 sort array by parity II
The blink code based on Arduino and esp8266 runs successfully (including error analysis)