DOM浅谈

先附上一个DOM的教程:http://www.w3school.com.cn/htmldom/dom_methods.asp

   DOM的结构实际上和数据结构里面的树非常相似

方法描述
getElementById() 返回带有指定 ID 的元素。
getElementsByTagName() 返回包含带有指定标签名称的所有元素的节点列表(集合/节点数组)。
getElementsByClassName() 返回包含带有指定类名的所有元素的节点列表。
appendChild() 把新的子节点添加到指定节点。
removeChild() 删除子节点。
replaceChild() 替换子节点。
insertBefore() 在指定的子节点前面插入新的子节点。
createAttribute() 创建属性节点。
createElement() 创建元素节点。
createTextNode() 创建文本节点。
getAttribute() 返回指定的属性值。
setAttribute() 把指定属性设置或修改为指定的值。

posted on 2017-12-25 23:30  isabellezhou  阅读(78)  评论(0编辑  收藏  举报

导航