原文:http://www.it130.cn/Article/FAQ/Web-kaifa/JavaScript/2007-3-20/2007032017013900.html
所属分类: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 它们有什么区别呢?相关推荐

  1. js中parentNode,parentElement,childNodes,children

    首先了解parentNode,parentElement,childNodes,children四大属性之前,必须对Dom树有一定的了解,在Dom文档结构中,HTML页面每一部分都是由节点组成的,节点 ...

  2. 深入了解parentNode,parentElement,childNodes,children的区别,一看就懂

    今天是准备面试的第七天,js是由ECMAScript.文档对象模型(DOM)和浏览器对象模型(BOM)组成,我们今天就了解下与DOM有关的常用接口parentNode,parentElement,ch ...

  3. parentNode,parentElement,childNodes,children最经典讲解

    首先了解parentNode,parentElement,childNodes,children四大属性之前,必须对Dom树有一定的了解,在Dom文档结构中,HTML页面每一部分都是由节点组成的,节点 ...

  4. 【转】parentNode,parentElement,childNodes,children最经典讲解

    点进去原文 首先了解parentNode,parentElement,childNodes,children四大属性之前,必须对Dom树有一定的了解,在Dom文档结构中,HTML页面每一部分都是由节点 ...

  5. 【JS】中parentNode,parentElement,childNodes,children之间的区别

    parentElement 获取对象层次中的父对象. parentNode 获取文档层次中的父对象. childNodes 获取作为指定对象直接后代的 HTML 元素和 TextNode 对象的集合. ...

  6. parentNode,parentElement,childNodes,children之间的区别

    parentElement 获取对象层次中的父对象.   parentNode 获取文档层次中的父对象.   childNodes 获取作为指定对象直接后代的 HTML 元素和 TextNode 对象 ...

  7. parentNode,parentElement,childNodes,children区别

    childNodes childNodes指的是返回当前元素子节点的所有类型节点,其中连空格和换行符都会默认文本节点 childNodes只会返回文本和元素的节点,并不能返回属性节点!!! child ...

  8. day31-33关于parentNode,parentElement,childNodes,children

    找节点和找元素是不同的. childNodes和children区别在于,childNodes可能会找到文本节点,而children只会找到元素节点. parentNode和parentElement ...

  9. parentNode,parentElement,childNodes,children的区别

    转自链接,https://blog.csdn.net/CODING_1/article/details/78202693 转载于:https://www.cnblogs.com/RioPlus/p/1 ...

  10. offsetParent与parentElement ,parentNode,parentElement,childNodes和children

    offsetParent直接的将是影响元素位置的上级element,而parentElement与位置显示无关时dom中的上级element. 例如:   <BODY>   <div ...

最新文章

  1. Ubuntu系统创建AndroidStudio启动图标(快捷方式)
  2. Unity3d 协程、调用函数、委托
  3. VMware Workstation三种网络连接模式说明(Bridged,NAT,Host-only networking)
  4. B00013 字符串哈希函数
  5. 面试精讲之面试考点及大厂真题 - 分布式专栏 07 说一说什么是正向代理,反向代理
  6. java collection源码_jdk源码阅读Collection实例分析
  7. 运筹学状态转移方程例子_如何确定动态规划的转移方程
  8. [k8s]kubernetes dashboard的安装
  9. 发送邮件 空格 java_java实现邮件发送功能
  10. 安装Git SCM for Windows
  11. Qt SQL 学习笔记二:qt建立数据库,创建和操纵表
  12. Python导入模块,Python import用法(超级详细)
  13. Foxit PDF SDK For Windows 完美Patch Foxit PDF SDK
  14. TensorFlow实践四步法
  15. Javascript 如何实现继承?
  16. 什么是重载?有什么作用?
  17. 直播回顾 | BPM平台与微服务架构天生契合(附资料下载)_Nebulogy_纳比云
  18. ip段各个号段的含义
  19. 灵动微 MM32 多路ADC-DMA配置
  20. MongoDB芒果数据库学习笔记一

热门文章

  1. feignRequest$Options错误
  2. play版 高德地图google_iOS 12 发布,苹果 CarPlay 终于开始支持谷歌、高德导航
  3. php数据库缓存服务器配置,php缓存技术(减少数据库服务器压力)
  4. php无限分类原理,php 递归无限级分类原理和实现代码
  5. 将日期转成指定格式_Excel小技巧——如何利用公式,快速将一串数字转换为日期格式...
  6. mysql insert 锁
  7. linux下常见的网络相关命令
  8. 误执行了rm -fr /*之后,除了跑路还能怎么办?!
  9. 微软推出 Pylance,改善 VS Code 中的 Python 体验
  10. 做程序员如何防止被裁员?我们既要干好主业,也要发展好副业,跟这些公众号大佬们向上生长...