I have an HTML string representing an element: '<li>text</li>'
. I'd like to append it to an element in the DOM (a ul
in my case). How can I do this with Prototype or with DOM methods?
(I know i could do this easily in jQuery, but unfortunately we're not using jQuery.)
Use insertAdjacentHTML(). It works with all current browsers, even with IE11.
With Prototype, you can also do:
HTML:
JS:
Use jnerator
For the heck of it I thought I'd share this over complicated but yet simple approach I came up with... Maybe someone will find something useful.
I am using this method (Works in IE9+), although it will not parse
<td>
or some other invalid direct childs of body: