首页
\
问答
\
如何将DOM元素附加到JavaScript中的空元素中?(How to append DOM Element into an empty element in JavaScript?)
如何将DOM元素附加到JavaScript中的空元素中?(How to append DOM Element into an empty element in JavaScript?)
我有一堆对象返回一个DOM树,然后我用它来附加到一个元素。 例如,
var elem = document.createElement('div'); elem.appendChild(callSomePrototypesMethod()); elem.appendChild(callSomePrototypesMethod()); elem.appendChild(callSomePrototypesMethod());
我最终会以如下方式结束:
<div> <div id="...">...</div> <div id="...">...</div> <div id="...">...</div> </div>
这三个DIV是由第三方代码创建的,我在这里将它们包裹在我的DIV标记中,但我想要的只是将它们附加到空元素,但它不起作用:
var elem = document.createElement(''); elem.appendChild(callSomePrototypesMethod()); elem.appendChild(callSomePrototypesMethod()); elem.appendChild(callSomePrototypesMethod());
预期成绩:
<div id="...">...</div> <div id="...">...</div> <div id="...">...</div>
我不确定这是否对您有意义,但我需要使用DOM,并且我不能将这些内容放入其他元素中。
I have bunch of objects that return a DOM-tree that I then use to append to an element. For example,
var elem = document.createElement('div'); elem.appendChild(callSomePrototypesMethod()); elem.appendChild(callSomePrototypesMethod()); elem.appendChild(callSomePrototypesMethod());
and I will eventually end up in something like:
<div> <div id="...">...</div> <div id="...">...</div> <div id="...">...</div> </div>
Those three DIVs were created by third party code, and I am wrapping them around my DIV tag here, but what I want instead is to just append them to an empty element, but it doesn't work:
var elem = document.createElement(''); elem.appendChild(callSomePrototypesMethod()); elem.appendChild(callSomePrototypesMethod()); elem.appendChild(callSomePrototypesMethod());
Expected results:
<div id="...">...</div> <div id="...">...</div> <div id="...">...</div>
I'm not sure if this makes any sense to you, but I need to use DOM, and I can't put those content within any other elements...
原文:https://stackoverflow.com/questions/1776481
更新时间:2023-06-14 12:06
最满意答案
看起来是他们最终的谷歌错误...
Looks to be a google error on their end...
相关问答
更多-
触发drawingManager的polygoncomplete-event并将自动创建的polygon-instance作为参数传递给回调( trigger第三个参数): polygonInstance = new google.maps.Polygon(/*options*/); google.maps.event.trigger(drawingManager, 'polygoncomplete', ...
-
在v3 API的早期阶段, getBounds()方法需要地图图块才能完成加载,以返回正确的结果。 但是现在看来,您可以收听bounds_changed事件,甚至在tilesloaded事件之前也会触发:
Google Maps v3 - getBounds is undefine ... -
看起来是他们最终的谷歌错误... http://www.google.com.au/about/jobs/locations/sydney/ Looks to be a google error on their end... http://www.google.com.au/about/jobs/locations/sydney/
-
我刚想通了怎么做! 1 - 在索引页面中插入谷歌的js代码,其中'rel =“forceload”'和'rev =“显示为'',如下所示: 2 - 您在模式页面中插入生成地图的代码,如下所示: