当前位置:网站首页>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 ,可阻止事件捕获
边栏推荐
- lombok常用注解
- JZ63 股票的最大利润
- Tas (file d'attente prioritaire)
- (C语言)输入一行字符,分别统计出其中英文字母、空格、数字和其它字符的个数。
- 中国交通标志检测数据集
- (C language) octal conversion decimal
- Fresh, 2022 advanced Android interview must know 100 questions (interview questions + answer analysis)
- 史上最易懂的f-string教程,收藏这一篇就够了
- SparkContext: Error initializing SparkContext解决方法
- Map和Set
猜你喜欢

Use sqoop to export ads layer data to MySQL

From scratch, develop a web office suite (3): mouse events

Jenkins voucher management

Depth filter of SvO2 series

mysql索引和事务

CDA data analysis -- Introduction and use of aarrr growth model

ThreadLocal的简单理解

Simple understanding of ThreadLocal

Take you ten days to easily finish the finale of go micro services (distributed transactions)

HR wonderful dividing line
随机推荐
Multiply LCA (nearest common ancestor)
基于Arduino和ESP8266的连接手机热点实验(成功)
China traffic sign detection data set
Sub thread get request
drools动态增加、修改、删除规则
Pytorch builds LSTM to realize clothing classification (fashionmnist)
Leetcode122 买卖股票的最佳时机 II
Deep understanding of P-R curve, ROC and AUC
Lekao: contents of the provisions on the responsibility of units for fire safety in the fire protection law
Calculate the maximum path sum of binary tree
drools执行指定的规则
Drools terminates the execution of other rules after executing one rule
post请求体内容无法重复获取
刷题---二叉树--2
Go学习笔记—基于Go的进程间通信
The differences and relationships among port, targetport, nodeport and containerport in kubenetes
AI中台技术调研
Codeforces 771-div2 C (trouble, permutation is not very good)
(C language) 3 small Codes: 1+2+3+ · · +100=? And judge whether a year is a leap year or a normal year? And calculate the circumference and area of the circle?
Drools dynamically add, modify, and delete rules