关于DOM的nodeType

*元素-1
< h1id = " h1 " > AnHTMLDocument < / h1>
varelement=document.getElementById("h1")
element.nodeType = 1
element.nodeName = H1
element.nodeValue = null

*文本-3
varelement = document.getElementById("h1")
vartext = element.
firstChild
text.nodeType = 3
text.nodeName = #text
text.nodeValue = An HTML Document
*文档-9
document.nodeType = 9
document.nodeName = #document
document.nodeValue = null
*属性-2
<input type="button" title="myTitle" id="myId" value="提交"/>
var button = document.getElementById("myId")
var attributes = button.attributes
var second = attributes[1]
second.nodeType = 2
second.nodeName = title
second.nodeValue = myTitle

你可能感兴趣的:(html)