当前位置:网站首页>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 ,可阻止事件捕獲
边栏推荐
- CDA data analysis -- Introduction and use of aarrr growth model
- How to write a pleasing English mathematical paper
- Introduction to CPU instruction set
- FastDateFormat为什么线程安全
- Intel internal instructions - AVX and avx2 learning notes
- Deep copy event bus
- 刷题---二叉树--2
- 初始JDBC 编程
- Docker compose configuration mysql, redis, mongodb
- OpenCV中cv2.VideoWriter_fourcc()函数和cv2.VideoWriter()函数的结合使用
猜你喜欢
Simple use of drools decision table
MySQL indexes and transactions
arcgis js 4.x 地图中加入图片
(C language) input a line of characters and count the number of English letters, spaces, numbers and other characters.
测试左移和右移
Docker compose configuration mysql, redis, mongodb
Programmers can't find jobs after the age of 35? After reading this article, you may be able to find the answer
High performance erasure code coding
浏览器存储方案
甜心教主:王心凌
随机推荐
[C language] convert decimal numbers to binary numbers
[I'm a mound pytorch tutorial] learning notes
kubeadm join时出现错误:[ERROR Port-10250]: Port 10250 is in use [ERROR FileAvailable--etc-kubernetes-pki
Deep copy event bus
Interview with meituan, a 34 year old programmer, was rejected: only those under the age of 30 who work hard and earn little overtime
mysql数据库基础
Map和Set
JZ63 股票的最大利润
Jenkins用户权限管理
Differences between nodes and sharding in ES cluster
Thesis translation: 2022_ PACDNN: A phase-aware composite deep neural network for speech enhancement
Error in kubeadm join: [error port-10250]: port 10250 is in use [error fileavailable--etc kubernetes PKI
Leetcode209 长度最小的子数组
排序---
Sub thread get request
OpenCV中cv2.VideoWriter_fourcc()函数和cv2.VideoWriter()函数的结合使用
MySQL and PostgreSQL methods to grab slow SQL
Go学习笔记—多线程
Sort---
Leetcode topic [array] -540- single element in an ordered array