閱讀82 返回首頁    go 阿裏雲 go 技術社區[雲棲]


常用DOM方法和屬性 小結

DOM主要方法

查找節點

element = document.getElementById(id)

elements = document.getElementsByTagName(tagName)

attributeValue = element.getAttribute(attributeName)

booleanValue = element.hasChildNodes()

創建節點

reference = document.createElement(element)

reference = document.createTextNode(text)

複製節點

reference = node.cloneNode(booleanValue)

插入節點

element.appendChild(newChild)

element.insertBefore(newNode, targetNode)

替換節點

element.replaceChild(newChild, oldChild)

設置節點屬性

element.setAttribute(attributeName, attributeValue)

刪除節點

element.removeChild(node)

DOM屬性

節點屬性

nodeName

nodeType

nodeValue

遍曆節點樹

childNodes

firstChild

lastChild

nextSibling

previousSibling

parentNode

 

 

 

 

 

最後更新:2017-04-03 15:21:56

  上一篇:go Struts 2 簡介 Struts2的基本流程
  下一篇:go Windows NT 驅動程序開發人員提示 -- 應注意避免的事項