当前位置:网站首页>js操作dom节点
js操作dom节点
2022-07-27 14:33:00 【IT_wangxianda】
最近学习Vue,Vue自动解析模板,发现用不到节点操作了,但是经常性的可能一个案例要用js,与Vue对比着来思考,学习,可其实js节点操作忘的差不多了,今天借鉴学习再次温习一下.
第一大类 通过元素类型方法来操作:(这种方法运用的最多)
document.getElementById();//id名,
document.getElementsByTagName();//标签名
document.getElementsByClassName();//类名
document.querySelector();//返回与该模式匹配的第一个元素,结果为一个元素;
document.querySelectorAll()//返回与该模式匹配的所有元素,结果为一个类数组
第二大类(一般为元素获取之后的再次关系元素节点的获取)
parentNode//获取所选节点的父节点,最顶层的节点为#document
childNodes //获取所选节点的子节点们
firstChild //获取所选节点的第一个子节点
lastChild //获取所选节点的最后一个子节点
nextSibling //获取所选节点的后一个兄弟节点
previousSibling //获取所选节点的前一兄弟节点
错误之处指正哦
边栏推荐
- js使用一元运算符简化字符串转数字
- JUC(JMM、Volatile)
- Deveco studio2.1 operation item error
- 【剑指offer】面试题46:把数字翻译成字符串——动态规划
- Tools - common methods of markdown editor
- After configuring corswebfilter in grain mall, an error is reported: resource sharing error:multiplealloworiginvalues
- 《吐血整理》C#一些常用的帮助类
- Alibaba's latest summary 2022 big factory interview real questions + comprehensive coverage of core knowledge points + detailed answers
- EMC design scheme of CAN bus
- Network equipment hard core technology insider router chapter Cisco asr9900 disassembly (I)
猜你喜欢

Leetcode 190. reverse binary bit operation /easy

EMC design scheme of RS485 interface

使用Lombok导致打印的tostring中缺少父类的属性

【剑指offer】面试题49:丑数

Spark 3.0 Adaptive Execution 代码实现及数据倾斜优化

数组名是首元素地址吗?

Implement custom spark optimization rules

The design method of integral operation circuit is introduced in detail

MLX90640 红外热成像仪测温传感器模块开发笔记(七)

Static关键字的三种用法
随机推荐
折半插入排序
使用解构交换两个变量的值
Network equipment hard core technology insider router Chapter 21 reconfigurable router
【剑指offer】面试题45:把数组排成最小的数
初识结构体
Network equipment hard core technology insider router chapter Cisco asr9900 disassembly (I)
C语言:动态内存函数
后台返回来的是这种数据,是什么格式啊
实现自定义Spark优化规则
直接插入排序
Multi table query_ Exercise 1 & Exercise 2 & Exercise 3
Watermelon book machine learning reading notes Chapter 1 Introduction
Pictures to be delivered
How to take satisfactory photos / videos from hololens
Singles cup, web:web check in
【剑指offer】面试题54:二叉搜索树的第k大节点
Summer Challenge harmonyos realizes a hand-painted board
Overview of wechat public platform development
Leetcode 191. number of 1 bits bit operation /easy
Tools - common methods of markdown editor