当前位置:网站首页>DOM day_04(7.12)BOM、打开新页面(延迟打开)、地址栏操作、浏览器信息读取、历史操作
DOM day_04(7.12)BOM、打开新页面(延迟打开)、地址栏操作、浏览器信息读取、历史操作
2022-07-26 22:38:00 【加1床铺盖】
复习
1.冒泡机制
(1)当子元素上发生事件时, 可以传递其父元素
(2)事件委托:
- 通过父元素帮助子元素完成事件
- 适合场景: 动态新增的子元素
(3)事件参数
- target: 此属性存储触发事件的
当事元素 - stopPropagation: 阻止冒泡事件
2.阻止默认事件: 事件参数中的 preventDefault. 主要用于超链接
3.鼠标点击的事件参数, 几组坐标值
- screenX, screenY: 相对屏幕左上角
- x, y: 相对浏览器内容区域的左上角
- offsetX, offsetY : 相较于点击事件发生的当事元素左上角
4.页面滚动事件: onscroll
- 读取偏移量:
document.documentElement.scrollTop || document.body.scrollTop
5.属性的旧版本操作
- getAttribute: 获取某属性的值
- setAttribute: 设置某属性的值
6.JS方式创建DOM元素
(1)追求极致性能: 放弃用HTML代码来书写, 直接用JS代码
document.createElement(标签名)
(2)文档片段: 提高 遍历创建DOM元素时的性能消耗
把遍历生成的DOM的元素先放在片段里, 最后把片段放到页面上
7.DOM的封装(选修)
- 利用函数的封装技巧, 把原生DOM进行了简化.
document.querySelectorAll->$- 提供了更多的原型方法, 自动实现遍历
- 这套思想就是
jQuery的封装思想
这套思想就是
jQuery的封装思想
DOM的套路就两点:
先找到要操作的元素
多个元素, 则需要遍历
操作元素的属性
一、BOM
Browser Object Model: 浏览器对象模型
用于操作浏览器上的各种属性

二、打开新页面

三、地址栏操作


四、浏览器信息读取

五、历史操作

边栏推荐
猜你喜欢

八皇后 N皇后

CSDN文章语法规则

关于Thymeleaf的表达式

关于Redis问题的二三事

信号与系统学习零输入响应

9_逻辑回归(Logistic Regression)

Viterbi Viterbi decoding bit error rate simulation, modulation is QPSK, channel is Gaussian white noise

并行MPI程序传递发送消息

13_集成学习和随机森林(Ensemble Learning and Random Forests)

RESNET paper interpretation and code implementation (pytorch)
随机推荐
A simple prime number program. Beginners hope that older bosses can have a look
Blue Bridge Cup 1004 [recursive] cow story
Leetcode - linked list
Eight queens n Queens
【Codeforces Round #808 (Div 2.) A·B·C】
[PCB open source sharing] stc8a8k64d4 development board
9_逻辑回归(Logistic Regression)
[4.9 detailed explanation of inclusion exclusion principle]
公司给了IP地址如何使用(详细版)
C语言 求素数、闰年以及最小公倍数最大公约数
Looking for the real murderer
RESNET paper interpretation and code implementation (pytorch)
The crawler parses the object of the web page. Element name method
My first blog - confused junior
"Could not load host key" error when xshell connects to the server
Sliding window problem summary
[4.7 Gauss elimination details]
postman的使用
信号与系统学习零输入响应
Three tier architecture simulation