六狼论坛

 找回密码
 立即注册

QQ登录

只需一步,快速开始

新浪微博账号登陆

只需一步,快速开始

搜索
查看: 72|回复: 0

关于DOM的nodeType

[复制链接]

升级  0%

58

主题

58

主题

58

主题

举人

Rank: 3Rank: 3

积分
200
 楼主| 发表于 2013-2-7 18:23:38 | 显示全部楼层 |阅读模式
*元素-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

您需要登录后才可以回帖 登录 | 立即注册 新浪微博账号登陆

本版积分规则

快速回复 返回顶部 返回列表