【作用】
表示文档,document对象是HTMLDocument(继承自Document类型)的一个实例,表示整个HTML页面。通过这个文档对象,可以取得与页面有关的信息,且能操作页面的外观及其底层结构。
【Document节点的特征】
document.nodeName
"#document"
document.nodeType
9
document.nodeValue
null
document.parentNode
null
document.ownerDocument
null
【文档的子节点】
![](https://i-blog.csdnimg.cn/blog_migrate/96c1cde47815b0a5072a861478079bcd.png)
【文档信息】
document.title
"Frameset Example"
document.title='改变'
"改变"
document.title='设置文档标题'
"设置文档标题"
document.url
undefined
document.URL
"http://localhost:19153/HtmlPage1.html"
//取得包含页面的域名
undefined
document.domain
"localhost"
//保存着链接到当前页面的那个页面的URL
document.referrer
""
![](https://i-blog.csdnimg.cn/blog_migrate/f5e96a3ab779de059e70509a9ac9048e.png)
【查找元素】
作用:取得特定的某个或某组元素的引用,然后执行一些操作。
方法 | 参数 | 备注 |
getElementById() | 要取得的元素的ID | |
getElementsByTagName() | 要取得元素的标签名 | 返回的是包含零或多个元素的NodeList |
getElementsByName() | 只有HTMLDocument类型才有,这个方法会返回所有带name特性的所有元素 |