js中nodeType类型

来源:互联网 发布:淘宝达人管理中心入口 编辑:程序博客网 时间:2024/04/29 18:07

· nodeType  (返回节点的类型,一般是整数)

· 元素element     1  ---指标签 <>

· 属性attr             2   <p color=""         getAttribute()   setAttribute()   使用attributes[]

· 如:alert( document.body.attributes["bgcolor"].nodeType);

· 文本text             3    #text

· 注释comments  8   <!--   -->

· 文档document   9   document   如:alert(window.document.nodeType);

 

nodeName:标签的名称,返回的结果都是大写, 文本的nodeName是#text,注释的nodeName是#comment

nodeValue:返回value,但是只对文本节点和注释有用,对于标签没有作用。

0 0
原创粉丝点击