在ie上,Mootools无法在另一个元素的底部注入一个元素

mootools fail to inject an element at bottom of another one on ie

本文关键字:元素 注入 一个 底部 Mootools ie 另一个      更新时间:2023-09-26

如果我试图在另一个元素的底部注入一个元素

var div = new Element('div', { id: 'thediv' }).inject(anotherdiv, 'bottom');

SCRIPT5007: Unable to get value of the property 'appendChild': object is null or undefined 
mootools-core-1.3.2-full-compat.js, line 3437 character 3

这些是在mootools1.3.2

中导致错误的行
bottom: function(context, element){
    element.appendChild(context);
},

如何解决这个问题?

如果anotherdiv没有appendChild方法,例如,如果脚本在anotherdiv存在之前运行,或者没有分配一个值,这是一个DOM元素。