原型Element.remove()在IE中不起作用 [英] Prototype Element.remove() not working in IE
问题描述
我有一个JavaScript函数,该函数通过ID获取DIV并进行克隆。然后,从DOM中删除原始DIV并插入克隆的对象。除了在IE中,其他一切都正常,因为从不删除原始DIV ...
I have a javascript function that gets a DIV by an ID and makes a clone. Then, removes the original DIV from DOM and inserts the cloned object..Everything works fine, except in IE, because the original DIV is never removed...
var loadingDiv = $(Sybil.conf.loadingDivId),
loadingClone = loadingDiv.clone(true);
console.log($$('.loadingImg'));
loadingDiv.remove();
//Insert the loading div on the page again
elt.insert({after: loadingClone});
[loadingClone].invoke(func);
console.log($$('.loadingImg'));
div的类中也有一个span,其中包含 loadingImg类,所以我只用了 console.log
检查有多少个元素。
FF始终打印 [span.loadingImg]
,但是IE打印 [span.loadingImg,span.loadingImg]
在第二个console.log上...
知道可能会发生什么吗?谢谢
The div also has a span inside with the class "loadingImg", so i just used the console.log
to check how many elements there are.
FF always prints [span.loadingImg]
but IE prints [span.loadingImg,span.loadingImg]
on the second console.log...
Any idea of what might be happening? Thanks
推荐答案
已解决。.实际上与JavaScript无关。.
div
我正在克隆的内部有 span
,但是 span
的关闭不正确,
经验教训:如果您知道一切正确,并且IE吓坏了,那就去搜索无效的HTML
Solved..nothing to do with the javascript actually..
The div
i was cloning had a span
inside, but the span
was not correctly closed, which makes IE goes mad..
Lesson learned: if you know everything is correct and IE is freaking out, go search for invalid HTML
这篇关于原型Element.remove()在IE中不起作用的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!