阮一峰的IT笔记:首页 -> 分类 -> Javascript 查看所有文章:按分类 | 按月份

动态创建内容的DOM方法

1. document.createElement(tagName)

创建由tagName指定的元素。

2. document.createTextNode(text)

创建一个包含静态文本的节点。

3. .appendChild(childNode)

appendChild方法将指定的节点增加到当前元素的子节点列表。

4. .getAttribute(name)

获得元素中name属性的值。

5. .setAttribute(name,value)

设置元素中name属性的值。

6. .insertBefore(newNode,targetNode)

将节点newNode作为当前元素的子节点插到targetNode元素前面。

7. .removeAttribute(name)

从元素中删除属性name。

8. .removeChild(childNode)

从元素中删除子元素childNode。

9. .replaceChild(newNode,oldNode)

将节点oldNode换成newNode。

10. .hasChildnodes()

返回一个布尔值,指示元素是否具有子元素。

(完)

« 读取XML文档示例:服务器返回美国州名列表 | 首页 | IE的DOM兼容性解决方法 »

About

This page contains a single entry from the blog posted on 2007年05月06日 20:23.

The previous post in this blog was 读取XML文档示例:服务器返回美国州名列表.

The next post in this blog is IE的DOM兼容性解决方法.

Many more can be found on the main index page or by looking through the archives.

Powered by
Movable Type 3.33

Post a comment