博客
关于我
强烈建议你试试无所不能的chatGPT,快点击我
[JS]DOM
阅读量:4613 次
发布时间:2019-06-09

本文共 874 字,大约阅读时间需要 2 分钟。

DOM : javascript的一部分,就是用来操作HTML的接口属性和方法。常见的有:getElementById

DOM树和DOM节点:

nodeType : 节点类型,常用的有1、3。IE前的版本无文本节点

DOM级别:

  0级(遗留DOM,IE4前的,像write等,不推荐用)

  1级(1998年指定,很多方法和接口,像firstChild等)

  2级(2000年指定,对事件模块,样式模块扩展1级功能,IE前的版本不支持)

  3级(很多浏览器还没支持,先不用关心啦)

常用的DOM操作:

  childNodes,children

  firstChild,firstElementChild

  lastChils,lastElementChild

  nextSibling,nextElementSibling

  previousSibling,previousElementSibling

  parentNode

  offsetParent : 有定位的父节点,无定位则为body

  offsetLeft : 到有定位的父节点左距离,无定位则到浏览器最左边距离(计算元素距离窗口的距离,offsetLeft和offsetParent配合,也可使用getBoundingClientRect)

  offsetWidth,clientWidth

  getAttrbute,setAttribute(了解就好,有兼容性)

  createElement

  appendChild

  insertBefore

  removeChild

  replaceChild

  cloneNode(布尔值) 

  document.documentElement : <html>

  document.body : <body>

  document.title : <title>

转载于:https://www.cnblogs.com/uedqd/archive/2013/02/17/2913930.html

你可能感兴趣的文章
动画原理——旋转
查看>>
Finding LCM LightOJ - 1215 (水题)
查看>>
python生成器
查看>>
PowerDesigner Constraint name uniqueness 错误
查看>>
系统子系统_GPRS子系统流程图
查看>>
为什么 NSLog 不支持 Swift 对象(转)
查看>>
Ubuntu 下搭建SVN服务器
查看>>
css3转换
查看>>
useradd -M -s /sbin/nologin mysql -g mysql 报错 Creating mailbox file
查看>>
python的字典和json转的互转
查看>>
WCF
查看>>
15.02.13-代码小技巧
查看>>
剑指offer31----栈的压入、弹出序列
查看>>
读取文件,按行输出
查看>>
UVA 11825 Hackers' Crackdown - 状压dp
查看>>
正则表达式
查看>>
向PHP发送HTTP-Get请求
查看>>
本周作业
查看>>
Python中的 matplotlib(二)随机漫步
查看>>
rsyslog 传输日志
查看>>