Js-parentNode、parentElement,childNodes、children 它们有什么区别呢?
所属分类:Web 开发 JavaScript
----------------------------------------------------------------------
parentNode、parentElement,childNodes、children 它们有什么区别呢?
----------------------------------------------------------------------
parentElement 获取对象层次中的父对象。
parentNode 获取文档层次中的父对象。
childNodes 获取作为指定对象直接后代的 HTML 元素和 TextNode 对象的集合。
children 获取作为对象直接后代的 DHTML 对象的集合。
--------------------------------------------------------
parentNode和parentElement功能一样,childNodes和children功能一样。但是parentNode和childNodes是符合W3C标准的,可以说比较通用。而另外两个只是IE支持,不是标准,Firefox就不支持
--------------------------------------------------------
用这parentNode,childNodes 2个就行了.楼上的都是正解!
--------------------------------------------------------
只是标准不一样吗?
--------------------------------------------------------
这个不是“标准不一样”,
另外两个根本就不是标准,
可以理解为ie自定义的
--------------------------------------------------------
也就是说parentElement、children是IE自家的东西,别的地方是不认的。
那么,他们的标准版就是parentNode,childNodes。
这两个的作用和parentElement、children是一样的,并且是标准的、通用的。
--------------------------------------------------------
以下是简单的解释,注意个别字的差异:
parentNode Property: Retrieves the parent object in the document hierarchy.
parentElement Property:Retrieves the parent object in the object hierarchy.
childNodes:
Retrieves a collection of HTML Elements and TextNode objects that are direct descendants of the specified object.
children:
Retrieves a collection of DHTML Objects that are direct descendants of the object.
--------------------------------------------------------
我也从dhtml手册里拿了两段^_^
parentElement children:
There is no public standard that applies to this property/collection.
parentNode childNodes:
This property/collection is defined in World Wide Web Consortium (W3C) Document Object Model (DOM) Level 1 .
很多W3C标准从IE5才开始支持
IE4以前的只能用ie自己的方法
转载于:https://www.cnblogs.com/htht66/archive/2007/10/03/913375.html
Js-parentNode、parentElement,childNodes、children 它们有什么区别呢?相关推荐
- js中parentNode,parentElement,childNodes,children
首先了解parentNode,parentElement,childNodes,children四大属性之前,必须对Dom树有一定的了解,在Dom文档结构中,HTML页面每一部分都是由节点组成的,节点 ...
- 深入了解parentNode,parentElement,childNodes,children的区别,一看就懂
今天是准备面试的第七天,js是由ECMAScript.文档对象模型(DOM)和浏览器对象模型(BOM)组成,我们今天就了解下与DOM有关的常用接口parentNode,parentElement,ch ...
- parentNode,parentElement,childNodes,children最经典讲解
首先了解parentNode,parentElement,childNodes,children四大属性之前,必须对Dom树有一定的了解,在Dom文档结构中,HTML页面每一部分都是由节点组成的,节点 ...
- 【转】parentNode,parentElement,childNodes,children最经典讲解
点进去原文 首先了解parentNode,parentElement,childNodes,children四大属性之前,必须对Dom树有一定的了解,在Dom文档结构中,HTML页面每一部分都是由节点 ...
- 【JS】中parentNode,parentElement,childNodes,children之间的区别
parentElement 获取对象层次中的父对象. parentNode 获取文档层次中的父对象. childNodes 获取作为指定对象直接后代的 HTML 元素和 TextNode 对象的集合. ...
- parentNode,parentElement,childNodes,children之间的区别
parentElement 获取对象层次中的父对象. parentNode 获取文档层次中的父对象. childNodes 获取作为指定对象直接后代的 HTML 元素和 TextNode 对象 ...
- parentNode,parentElement,childNodes,children区别
childNodes childNodes指的是返回当前元素子节点的所有类型节点,其中连空格和换行符都会默认文本节点 childNodes只会返回文本和元素的节点,并不能返回属性节点!!! child ...
- day31-33关于parentNode,parentElement,childNodes,children
找节点和找元素是不同的. childNodes和children区别在于,childNodes可能会找到文本节点,而children只会找到元素节点. parentNode和parentElement ...
- parentNode,parentElement,childNodes,children的区别
转自链接,https://blog.csdn.net/CODING_1/article/details/78202693 转载于:https://www.cnblogs.com/RioPlus/p/1 ...
- offsetParent与parentElement ,parentNode,parentElement,childNodes和children
offsetParent直接的将是影响元素位置的上级element,而parentElement与位置显示无关时dom中的上级element. 例如: <BODY> <div ...
最新文章
- Ubuntu系统创建AndroidStudio启动图标(快捷方式)
- Unity3d 协程、调用函数、委托
- VMware Workstation三种网络连接模式说明(Bridged,NAT,Host-only networking)
- B00013 字符串哈希函数
- 面试精讲之面试考点及大厂真题 - 分布式专栏 07 说一说什么是正向代理,反向代理
- java collection源码_jdk源码阅读Collection实例分析
- 运筹学状态转移方程例子_如何确定动态规划的转移方程
- [k8s]kubernetes dashboard的安装
- 发送邮件 空格 java_java实现邮件发送功能
- 安装Git SCM for Windows
- Qt SQL 学习笔记二:qt建立数据库,创建和操纵表
- Python导入模块,Python import用法(超级详细)
- Foxit PDF SDK For Windows 完美Patch Foxit PDF SDK
- TensorFlow实践四步法
- Javascript 如何实现继承?
- 什么是重载?有什么作用?
- 直播回顾 | BPM平台与微服务架构天生契合(附资料下载)_Nebulogy_纳比云
- ip段各个号段的含义
- 灵动微 MM32 多路ADC-DMA配置
- MongoDB芒果数据库学习笔记一
热门文章
- feignRequest$Options错误
- play版 高德地图google_iOS 12 发布,苹果 CarPlay 终于开始支持谷歌、高德导航
- php数据库缓存服务器配置,php缓存技术(减少数据库服务器压力)
- php无限分类原理,php 递归无限级分类原理和实现代码
- 将日期转成指定格式_Excel小技巧——如何利用公式,快速将一串数字转换为日期格式...
- mysql insert 锁
- linux下常见的网络相关命令
- 误执行了rm -fr /*之后,除了跑路还能怎么办?!
- 微软推出 Pylance,改善 VS Code 中的 Python 体验
- 做程序员如何防止被裁员?我们既要干好主业,也要发展好副业,跟这些公众号大佬们向上生长...