IE6 / IE7中的appendChild不适用于现有元素 [英] appendChild in IE6/IE7 does not work with existing elements

查看:267
本文介绍了IE6 / IE7中的appendChild不适用于现有元素的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我有一个div需要在DOM中从一个地方移动到另一个地方。所以现在我这样做是这样的:

  flex.utils.get('oPopup_About')。appendChild(flex。 utils.get( 'oUpdater_About')); 

但是,IE,那么,IE,它不起作用。它的作品是所有其他浏览器,只是不在IE中。



我需要这样做,因为元素(div)'oUpdater_About'需要要重复使用,因为它一直在填充。



所以我只需要能够移动DOM在DOM附近,appendChild将让所有浏览器发生这种情况,但是,IE。



提前感谢

解决方案

先删除节点,然后再将其附加到其他位置。
一个节点不能同时在两个地方。

  var node = flex.utils.get('oUpdater_About')
node.parentNode.removeChild(node);
flex.utils.get('oPopup_About')。appendChild(node);


I have a div that needs to be moved from one place to another in the DOM. So at the moment I am doing it like so:

flex.utils.get('oPopup_About').appendChild(flex.utils.get('oUpdater_About'));

But, IE, being, well, IE, it doesn't work. It works all other browsers, just not in IE.

I need to do it this way as the element (div) 'oUpdater_About' needs to be reused as it is populated over and over.

So i just need to be able to move the div around the DOM, appendChild will let this happen in all browsers, but, IE.

Thanks in advance!

解决方案

You have to remove the node first, before you can append it anywhere else. One node cannot be at two places at the same time.

var node = flex.utils.get('oUpdater_About')
node.parentNode.removeChild(node);
flex.utils.get('oPopup_About').appendChild(node);

这篇关于IE6 / IE7中的appendChild不适用于现有元素的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆