I need a way to append HTML to a container element without using innerHTML.
(我需要一种方法将HTML附加到容器元素而不使用innerHTML。)
The reason why I do not want to use innerHTML is because when it is use like this:(我不想使用innerHTML的原因是因为它使用时如下:)
element.innerHTML += htmldata
It works by replacing all of the html first before adding the old html plus the new html.
(它的工作原理是在添加旧的html和新的html之前先替换所有的html。)
This is not good because it resets dynamic media such as embedded flash videos...(这不好,因为它重置了嵌入式Flash视频等动态媒体......)
I could do it this way which works:
(我能用这种方式做到这一点:)
var e = document.createElement('span');
e.innerHTML = htmldata;
element.appendChild(e);
However the problem with that way is that there is that extra span tag in the document now which I do not want.
(然而,这种方式的问题是文档中现在有额外的span标记,我不想要。)
How can this be done then?
(那怎么办呢?)
Thanks!(谢谢!)
ask by Bob translate from so
与恶龙缠斗过久,自身亦成为恶龙;凝视深渊过久,深渊将回以凝视…