我有一个javascript项目,有一些代码我用来在div中创建一些子div:
var fragment = document.createDocumentFragment();
// code here to add divs in fragment
this._container.appendChild(fragment);
'此'是我创建的对象, _container 是div。 this._container肯定是一个现有的div。在this._container.appendChild(片段)之后,div正确显示在我的html表单上。
当我在Visual Studio中调试它时,片段中的元素显示在文档下。
有人知道为什么吗?提前谢谢。
答案 0 :(得分:0)
这取决于代码运行的上下文,它设置 this 的值。
检查this._container的值。