问题:
I have an HTML string representing an element: '<li>text</li>'
. 我有一个表示元素的HTML字符串: '<li>text</li>'
。 I'd like to append it to an element in the DOM (a ul
in my case). 我想将其附加到DOM中的元素(以我的情况为ul
)。 How can I do this with Prototype or with DOM methods? 如何使用Prototype或DOM方法做到这一点?
(I know i could do this easily in jQuery, but unfortunately we're not using jQuery.) (我知道我可以在jQuery中轻松完成此操作,但不幸的是,我们没有使用jQuery。)
解决方案:
参考一: https://stackoom.com/question/24Y3/使用内置DOM方法或原型从HTML字符串创建新的DOM元素参考二: https://oldbug.net/q/24Y3/Creating-a-new-DOM-element-from-an-HTML-string-using-built-in-DOM-methods-or-Prototype
来源:oschina
链接:https://my.oschina.net/u/3797416/blog/4283983