DOM总结

1. 创建

  • document.write()

  • innerHTML

  • document.createElement()

  • 2.增加

  • appendChild

  • insertBefore
    3.删除

  • removeChild
    4.修改

  • 修改元素属性:src、href、title

  • 修改普通元素内容:innerHTML、innerText

  • 修改表单元素:value、type

  • 修改元素样式:style、className
    5.查

  • DOM提供的API方法:getElementById、getElementsByName 此方法比较老旧不建议使用

  • H5提供得新方法:querySelector、querySelectorAll 提倡

  • 利用节点获取元素:父(parentNode)、子(children)、兄(previousElementSibling、nextElementSibling)提倡
    6.自定义属性

  • setAttribute:设置dom得属性值

  • getAttribute:得到dom得属性值

  • removeAttribute:移除属性
    7.事件操作
    DOM总结:创建、增删改查、自定义属性、事件操作

相关文章:

  • 2021-12-04
  • 2021-04-27
  • 2021-12-26
  • 2022-12-23
  • 2021-12-15
  • 2022-12-23
  • 2021-11-13
猜你喜欢
  • 2021-08-31
  • 2022-12-23
  • 2022-12-23
  • 2022-12-23
  • 2021-12-28
  • 2022-12-23
  • 2022-02-22
相关资源
相似解决方案