阅读82 返回首页    go iPhone_iPad_Mac_apple


常用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 驱动程序开发人员提示 -- 应注意避免的事项