当前位置:网站首页>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 ,可阻止事件捕获
边栏推荐
- Docker-compose配置Mysql,Redis,MongoDB
- Simple use of drools decision table
- SCM power supply
- post请求体内容无法重复获取
- [C language] Yang Hui triangle, customize the number of lines of the triangle
- arcgis js 4. Add pictures to x map
- Brush questions --- binary tree --2
- Full link voltage measurement
- [C language] convert decimal numbers to binary numbers
- (C语言)3个小代码:1+2+3+···+100=?和判断一个年份是闰年还是平年?和计算圆的周长和面积?
猜你喜欢

CDH6之Sqoop添加数据库驱动

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

(C语言)输入一行字符,分别统计出其中英文字母、空格、数字和其它字符的个数。

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

Sort---

Lekao: contents of the provisions on the responsibility of units for fire safety in the fire protection law

Sparkcontext: error initializing sparkcontext solution

Deep understanding of P-R curve, ROC and AUC

Simple use of drools decision table

drools动态增加、修改、删除规则
随机推荐
二分刷题记录(洛谷题单)区间的甄别
排序---
AI中台技术调研
drools执行完某个规则后终止别的规则执行
Less than three months after the programmer was hired, the boss wanted to launch the app within one month. If he was dissatisfied, he was dismissed immediately
The blink code based on Arduino and esp8266 runs successfully (including error analysis)
drools执行String规则或执行某个规则文件
Jenkins voucher management
输入一个三位的数字,输出它的个位数,十位数、百位数。
还不会安装WSL 2?看这一篇文章就够了
LeetCode—剑指 Offer 59 - I、59 - II
drools动态增加、修改、删除规则
甜心教主:王心凌
倍增 LCA(最近公共祖先)
mysql索引和事务
Leetcode14 最长公共前缀
Discrimination of the interval of dichotomy question brushing record (Luogu question sheet)
Leetcode739 daily temperature
堆(優先級隊列)
(C语言)3个小代码:1+2+3+···+100=?和判断一个年份是闰年还是平年?和计算圆的周长和面积?