如何实现浏览器兼容版的element.children
来源:互联网 发布:淘宝花呗分期手续费 编辑:程序博客网 时间:2024/05/18 22:51
element.children这个获取节点子节点的方法支持ie9及以上版本,为了能够兼容低版本的ie,可参考一下的代码实现兼容,具体的参考资料是MDN上的实现方法:
// Overwrites native 'children' prototype.// Adds Document & DocumentFragment support for IE9 & Safari.// Returns array instead of HTMLCollection.(function(constructor) { if (constructor && constructor.prototype && constructor.prototype.children == null) { Object.defineProperty(constructor.prototype, 'children', { get: function() { var i = 0, node, nodes = this.childNodes, children = []; while (node = nodes[i++]) { if (node.nodeType === 1) { children.push(node); } } return children; } }); }})(window.Node || window.Element);
阅读全文
0 0
- 如何实现浏览器兼容版的element.children
- 实现浏览器兼容版的element.children
- 如何实现浏览器兼容版的element.dataset
- 实现浏览器兼容版的element.dataset
- 如何实现浏览器兼容版的inline-block显示
- 如何实现浏览器兼容版的window.getComputedStyle
- 浏览器兼容element.dataset
- 实现浏览器兼容版的window.getComputedStyle
- 实现浏览器兼容版的inline-block显示
- 如何解决CSS浏览器兼容的问题
- 不同浏览器的JS如何兼容?
- 兼容浏览器的js Ajax实现
- CSS兼容实现各浏览器的透明度
- 实现ie浏览器对placeholder的兼容
- 利用滤镜实现不同浏览器的兼容
- 浏览器兼容如何IE11
- 如何实现背景透明,文字不透明,兼容所有浏览器?
- Element与Node的区别,children与childNodes的区别
- POJ 1312 Numerically Speaking 笔记
- Storm on YARN
- 构建乘积数组
- Java 对象的生命周期
- B树与B+树(好文推荐)
- 如何实现浏览器兼容版的element.children
- ubuntu下编译uclinux skyeye上运行
- LNMP环境问题--nginx不解析php文件
- mybatis generator结合maven与ant完成数据库的逆向工程
- 元件库制作
- 工厂方法模式
- 下拉菜单的实现
- SMTP命令
- 关于0x80000000为什么等于-2147483648和负数在内存上储存的问题