IE7中的Element.prototype? [英] Element.prototype in IE7?
本文介绍了IE7中的Element.prototype?的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!
问题描述
我想扩展所有的dom元素,以便我可以获取和删除他们的孩子。该功能在下面(在FF和Chrome中工作)。在IE7中是否有等同于扩展基础dom对象?
I'm trying to extend all dom elements so i can get and remove their children. The function is below (works in FF and Chrome). Is there an equivalent in IE7 to extend the base dom object?
if (!Element.get) {
Element.prototype.get = function(id) {
for (var i = 0; i < this.childNodes.length; i++) {
if (this.childNodes[i].id == id) {
return this.childNodes[i];
}
if (this.childNodes[i].childNodes.length) {
var ret = this.childNodes[i].get(id);
if (ret != null) {
return ret;
}
}
}
return null;
}
}
Element.prototype.removeChildren = function() {
removeChildren(this);
}
谢谢!
推荐答案
不。将有一些有限的支持在IE8中,但是,直到那时,你最好找另一个地方挂掉你的功能。
No. There will be some limited support in IE8, but 'till then you're better off finding another place to hang your functions.
这篇关于IE7中的Element.prototype?的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!
查看全文