JS的DOM结构树,查找元素

时间:2021-07-26 22:36:55   收藏:0   阅读:68

DOM结构树:

技术分享图片

查找元素:

1.getElementById() 方法定义在Document.prototype上,也就是说在element上不能使用

2.getElementsByName() 方法定义在HTMLDocument.prototype上,即非HTML不能使用(XML不能使用)

3.getElementsByTagName() 方法定义在Document.prototype和Element.prototype上;

4.HTMLDcoument定义了一些常用的属性 body、head分别代表了HTML文档中的body和head标签

5.Document.prototype上定义了document.documentEelement属性,指的是文档的根元素,在html文档中代表html标签

6.querySelector()、querySelectorAll()、getElementsByClassName() IE8及以下浏览器不兼容,定义在Document.prototype和Element.prototype上

 

原文:https://www.cnblogs.com/chenhuaiyou/p/14917936.html

评论(0
© 2014 bubuko.com 版权所有 - 联系我们:wmxa8@hotmail.com
打开技术之扣,分享程序人生!