標籤:des style ar sp for java strong on bs
一、尋找:
getElementById() 方法返回帶有指定 ID 的元素(唯一):
getElementsByTagName() 返回包含帶有指定標籤名稱的所有元素的節點列表(集合/節點數組)。
getElementsByClassName() 返回包含帶有指定類名的所有元素的節點列表(集合/節點數組)。
parentNode - 節點(元素)的父節點
childNodes - 節點(元素)的子節點
元素的首個子項目(firstChild)
元素的最後一個子項目(lastChild)
attributes - 節點(元素)的屬性節點
document.documentElement - 全部文檔
document.body - 文檔的主體
二、建立:
createAttribute() 建立屬性節點。
createElement() 建立元素節點。
createTextNode() 建立文本節點。
var oFragment = document.createDocumentFragment(); 建立文本片段
三、插入:
appendChild() 把新的子節點添加到指定節點。
replaceChild() 替換子節點。parent.replaceChild(para,child);
insertBefore() 在指定的子節點前面插入新的子節點。parent.insertBefore(new,child)
四、刪除:
removeChild() 刪除子節點。
五、操作:
getAttribute() 返回指定的屬性值。
setAttribute() 把指定屬性設定或修改為指定的值。
innerHTML - 節點(元素)的文本值
nodeName 屬性規定節點的名稱。
nodeValue 屬性規定節點的值。
nodeType 屬性返回節點的類型。nodeType 是唯讀。
| 元素類型 |
NodeType |
| 元素 |
1 |
| 屬性 |
2 |
| 文本 |
3 |
| 注釋 |
8 |
| 文檔 |
9 |
javascript原生API總結