JS入门笔记

DOM有四种节点:

1. 元素节点:即标签
2. 属性节点:写在标签里的属性
3. 文本节点:嵌在元素节点里展示出来的文本
4. 文档节点:document

获取元素节点的三种常用方法:

1.ById

2.ByName

3.ByTagName

获取文本节点内容使用innerHTML

插入节点:

先document.createElement,再appendChild、insertBefore

判断节点类型,用nodeType属性:

Value Type
1 element
3 text
7 preprocessing instruction
8 comment
9 document
10 document_type
11 document_fragment
原文地址:https://www.cnblogs.com/leegent/p/5241880.html