The childNodes property contains all of the immediate children of the element. There is a significant difference between browsers regarding the identification of these nodes. For example, consider the following code:

 <ul id="myList">
<li>Item 1</li>
<li>Item 2</li>
<li>Item 3</li>
<ul>

  When this code is parsed in IE8 and earlier, the <ul> element has three child nodes, one for each of the <li> elements. In all other browsers, the <ul> element has seven elements: three <li> elements and four text nodes representing the white space between <li> elements. It's important to keep these browser differences in mind when navigating children using the childNodes property. Oftentimes, it's necessary to check the nodeType before performing an action, as the following example shows:

 for (var i=0, len=element.childNodes.length; i<len; i++){
if (element.childNodes[i].nodeType == 1){
// do processing
}
}

最新文章

  1. Ajax基础
  2. Linux命令学习-mkdir
  3. jQuery页面加载后执行的事件(3种方式)
  4. ok6410内存初始化
  5. 在PyCharm里配置SubVersion
  6. Python报错TypeError: &#39;&lt;&#39; not supported between instances of &#39;str&#39; and &#39;int&#39;
  7. connect socket的超时设置
  8. python从零开始 -- 第2篇之python版本差异
  9. Asp.net连接数据库的配置方法
  10. JavaScript面试技巧(二):JS-Web-API
  11. cf 1132 F
  12. Unity shader学习之标准的Unity shader
  13. python中进制之间的转换
  14. 阿里巴巴Dubbo实现的源码分析
  15. 虚拟机VirtualBox安装MAC OS 10.12图文教程
  16. Codeforces Round #370 (Div. 2) B. Memory and Trident 水题
  17. ajax访问WebService跨域问题
  18. iOS 网络缓存总结
  19. 手动安装sublime插件babel-sublime
  20. Qt-网易云音乐界面实现-5 收藏列表,播放列表实现 QListWidget QTableWidget

热门文章

  1. python 文件操作的相对路径和绝对路径(windows)
  2. java8 Date Localdatetime instant 相互转化(转) 及当天的最大/最小时间
  3. 【Winform-自定义控件】一个自定义的进度条
  4. 【Winform-自定义控件】 DataGridView多维表头
  5. 卸载python
  6. Prism框架实战——订餐软件
  7. js 获取 touch length
  8. 51 Nod 1352 集合计数
  9. Python 简易Cmd控制
  10. Java实验课:命令行参数是什么?