当前位置:网站首页>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 ,可阻止事件捕获
边栏推荐
- Go学习笔记—基于Go的进程间通信
- FastDateFormat为什么线程安全
- Simple use of drools decision table
- 【C语言】杨辉三角,自定义三角的行数
- 高性能纠删码编码
- Uniapp uni list item @click, uniapp uni list item jump with parameters
- mysql数据库基础
- Day12 control flow if switch while do While guessing numbers game
- 上传文件时,服务器报错:IOFileUploadException: Processing of multipart/form-data request failed. 设备上没有空间
- Use sqoop to export ads layer data to MySQL
猜你喜欢

How does Premiere (PR) import the preset mogrt template?

conda常用命令汇总

Initial JDBC programming

堆(优先级队列)

ThreadLocal的简单理解

Record the range of data that MySQL update will lock

ES集群中节点与分片的区别

(C语言)3个小代码:1+2+3+···+100=?和判断一个年份是闰年还是平年?和计算圆的周长和面积?

基于Arduino和ESP8266的连接手机热点实验(成功)

WSL 2 will not be installed yet? It's enough to read this article
随机推荐
ThreadLocal的简单理解
The most understandable f-string tutorial in history, collecting this one is enough
【工控老马】西门子PLC Siemens PLC TCP协议详解
Deep understanding of NN in pytorch Embedding
Go学习笔记—多线程
kubeadm join时出现错误:[ERROR Port-10250]: Port 10250 is in use [ERROR FileAvailable--etc-kubernetes-pki
Uniapp uni list item @click, uniapp uni list item jump with parameters
Embedded Software Engineer career planning
(C language) octal conversion decimal
Those logs in MySQL
[I'm a mound pytorch tutorial] learning notes
Simple understanding of ThreadLocal
Le tutoriel F - String le plus facile à comprendre de l'histoire.
HR wonderful dividing line
conda常用命令汇总
drools决策表的简单使用
MySQL与PostgreSQL抓取慢sql的方法
post请求体内容无法重复获取
The second composition template of postgraduate entrance examination English / chart composition, English chart composition is enough
LeetCode—剑指 Offer 59 - I、59 - II