Prototype Element.remove() not working in IE

社会主义新天地 提交于 2019-12-13 06:43:00

问题


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'));

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


回答1:


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



来源:https://stackoverflow.com/questions/2860757/prototype-element-remove-not-working-in-ie

易学教程内所有资源均来自网络或用户发布的内容,如有违反法律规定的内容欢迎反馈
该文章没有解决你所遇到的问题?点击提问,说说你的问题,让更多的人一起探讨吧!