页面源代码
<!DOCTYPE html> <html lang="en"> <head> <meta charset="UTF-8"> <title></title> </head> <body> <h2 id="header">前端开发学习</h2> <ul class="list"> <li>HTML5</li> <li>CSS3</li> <li>JavaScript</li> </ul> </body> </html>
一:点的增删改查
获取页面中的 h2 属性节点
1. 查询
2. 添加 class 属性
添加 style 属性
3. 修改 class 属性
修改 style 属性
二:Attribute 的增删改查
1. 查询标签属性 getAttribute
2. 添加 class 、style 属性 - setAttribute
3. 删除 class 属性
三:attributes 的增删改查
1. 查询属性
2. 删除 style 属性