javascript中DOM节点
nodeName
nodeName 属性含有某个节点的名称。
元素节点的 nodeName 是标签名称
属性节点的 nodeName 是属性名称
文本节点的 nodeName 永远是 #text
文档节点的 nodeName 永远是 #document
注释:nodeName 所包含的 XML 元素的标签名称永远是大写的
nodeValue
对于文本节点,nodeValue 属性包含文本。
对于属性节点,nodeValue 属性包含属性值。
nodeValue 属性对于文档节点和元素节点是不可用的。
nodeType
作 用
辨识节点的DOM 型态。
基本语法
numNodeType = xmlDocNode.nodeType ;
说 明
此属性只读且传回一个数值。
有效的数值符合以下的型别:
1-ELEMENT (元素)
2-ATTRIBUTE (属性)
3-TEXT (文本)
4-CDATA
5-ENTITY REFERENCE
6-ENTITY
7-PI (processing instruction)
8-COMMENT (注释)
9-DOCUMENT ()
10-DOCUMENT TYPE
11-DOCUMENT FRAGMENT
12-NOTATION
范 例
numNodeType = xmlDoc.documentElement.nodeType;
alert(numNodeType);
Node Types
节点类型
The following table lists the different W3C node types, and which node types they may have as children:
下述表格列举了不同的W3C节点类型,每个节点类型中可能会包含子类:
Node type
节点类型Description
描述Children
子类
Document
文档
Represents the entire document (it is the root-node of the DOM tree)
定义整个文档(DOM树的根节点)
Element (max. one), ProcessingInstruction, Comment, DocumentType
DocumentFragment
文档片断
Represents a "lightweight" Document object, which can hold a portion of a document
定义“lightweight”文档对象(保留一个文档中的一部分)
Element, ProcessingInstruction, Comment, Text, CDATASection, EntityReference
DocumentType
文档类型
Represents a list of the entities that are defined for the document
定义文档的实体列表
None
EntityReference
实体参数
Represents an entity reference
定义一个实体参数
Element, ProcessingInstruction, Comment, Text, CDATASection, EntityReference
Element
元素
Represents an element
定义一个元素
Element, Text, Comment, ProcessingInstruction, CDATASection, EntityReference
Attr
属性
Represents an attribute. Not
相关文档:
页面提交数据一般有两种方法:get,post。post就是所谓的form提交,使用视图;get是通过url提交。
Get方法一般用后台代码(如asp,asp.net)获得参数,代码很简单:Request.QueryString["id"];即可获取。
有些时候需要直接在前台获取url参数,要用到javascript,js没有直接获取url参数的方法,那么,我们如何通过js ......
这篇开始会分析流行的js库之写类方式。各种库的写类方式虽然千奇百怪,但仍然逃离不了本质---用构造函数和原型
来组装类。
6、Prototype.js的写类方式
//prototype.js中的代码
var Class = {
create: function() {
return function() {
this.initialize.apply(this, arguments);
}
}
}
//简化 ......
<html>
<head>
<title>changePage</title>
</head>
<body>
<table id="pic" cellpadding="0" cellspacing="0" border="1" width="200" height="100" bordercolor="red">
<tr>
<td>picture chanage!</td>
</tr>
</table>
< ......