Js-parentNode、parentElement,childNodes、children 的区别
来源:互联网 发布:加快音乐的软件 编辑:程序博客网 时间:2024/05/17 02:08
----------------------------------------------------------------------
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自己的方法
提示:您可以先修改部分代码再运行
看见没有,这里的这个bbb,影响了结果
本文出自 51CTO.COM技术博客
- Js-parentNode、parentElement,childNodes、children 的区别
- Js中parentNode,parentElement,childNodes,children之间的区别
- parentNode,parentElement,childNodes,children的区别
- parentNode、parentElement,childNodes、children 区别
- Js-parentNode、parentElement,childNodes、children 它们有什么区别呢?
- parentElement parentNode childNodes children
- parentNode、parentElement,childNodes、children
- parentNode,parentElement,childNodes,children最经典讲解
- offsetParent与parentElement ,parentNode,parentElement,childNodes和children
- offsetParent与parentElement ,parentNode,parentElement,childNodes和children
- parentNode,childNodes、children 的使用
- parentNode,childNodes、children 的使用
- parentElement和parentNode的区别
- JS children和childNodes的区别
- parentNode,parentElement 区别
- children的childNodes区别
- javascript中parentNode,childNodes,children的应用详解
- children和childNodes 的区别
- 行为规范(笛卡尔)
- word-break:break-all和word-wrap:break-word
- 有关DirectSoundFullDuplexCreate8的问题
- WINCE下OPENGL ES建模与贴纹理的示例程序
- c语言输入输出函数printf与scanf
- Js-parentNode、parentElement,childNodes、children 的区别
- PPP协议基础
- Oracle对null的排序
- Jquery 获取指定 table下 所有 type='text' 的 input
- Oracle对当前时间的加减处理
- en~试下live writer~
- Frequently Asked Questions(MPICH2)
- AjaxControlToolkit中,TabContainer
- 找工作中……