当前位置:网站首页>BOM DOM
BOM DOM
2022-07-02 12:36: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 ,可阻止事件捕獲
边栏推荐
- Gaode map test case
- CDA数据分析——AARRR增长模型的介绍、使用
- Sweetheart leader: Wang Xinling
- H5 to app
- mysql索引和事务
- [I'm a mound pytorch tutorial] learning notes
- Sse/avx instruction set and API of SIMD
- 全链路压测
- Performance tuning project case
- There is a hidden danger in CDH: the exchange memory used by the process of this role is XX megabytes. Warning threshold: 200 bytes
猜你喜欢

Anxiety of a 211 programmer: working for 3 years with a monthly salary of less than 30000, worried about being replaced by fresh students

drools决策表的简单使用

Discrimination of the interval of dichotomy question brushing record (Luogu question sheet)

二分刷题记录(洛谷题单)区间的甄别

Docker compose configuration mysql, redis, mongodb

kubenetes中port、targetPort、nodePort、containerPort的区别与联系

Test shift left and right

Drools dynamically add, modify, and delete rules

Find the common ancestor of any two numbers in a binary tree

China traffic sign detection data set
随机推荐
初始JDBC 编程
China traffic sign detection data set
Leetcode122 买卖股票的最佳时机 II
怎样写一篇赏心悦目的英文数学论文
drools动态增加、修改、删除规则
(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?
Leetcode209 subarray with the smallest length
FastDateFormat为什么线程安全
Writing method of then part in drools
Drools terminates the execution of other rules after executing one rule
ES集群中节点与分片的区别
Deep understanding of P-R curve, ROC and AUC
Record the range of data that MySQL update will lock
mysql索引和事务
Distributed machine learning framework and high-dimensional real-time recommendation system
防抖 节流
上传文件时,服务器报错:IOFileUploadException: Processing of multipart/form-data request failed. 设备上没有空间
arcgis js 4. Add pictures to x map
Leetcode922 按奇偶排序数组 II
Simple understanding of ThreadLocal