• 博客园logo
  • 会员
  • 众包
  • 新闻
  • 博问
  • 闪存
  • 赞助商
  • HarmonyOS
  • Chat2DB
    • 搜索
      所有博客
    • 搜索
      当前博客
  • 写随笔 我的博客 短消息 简洁模式
    用户头像
    我的博客 我的园子 账号设置 会员中心 简洁模式 ... 退出登录
    注册 登录
向阳光大道勇猛前进吧,了解但不走偏门!
            管理     

常见DOM操作

 

1.childNode.before()

2.childNode.after()

3.childNode.replaceWith()               //内容替换

4.parentNode.prepend()                   //插入子节点

5.parentNode.append()                    //插入子节点

 

属性方法:

Element.getAttribute():读取指定属性

Element.setAttribute():设置指定属性

查找方法:

Element.querySelector()

Element.querySelectorAll()

Element.getElementsByTagName()

Element.getElementsByClassName()

生成节点

document.createElement(tagName) //用来生成HTML元素节点。

document.createTextNode(text) //用来生成文本节点

document.createAttribute(name) //生成一个新的属性对象节点,并返回它。

 

圣凡无二路,方便有多门。
posted @ 2018-11-19 20:02  优昙陀罗  阅读(170)  评论(0)    收藏  举报
刷新页面返回顶部
博客园  ©  2004-2025
浙公网安备 33010602011771号 浙ICP备2021040463号-3