I'm trying to create an element dynamically using an HTML string. Here's a simple example using both prototype and DOM:
// HTML string
var s = '<li>text</li>';
// DOM
var el1 = document.createElement(s);
// prototype
var el2 = new Element(s);
$('mylist').appendChild(el1);
$('mylist').appendChild(el2);
Both approaches insert an empty listitem to the list.
I know that using prototype's Element as a constructor requires a tagName and an optional attributes parameter, but I figured it may let me pass in an HTML string too.
However, MSDN states "You can also specify all the attributes inside the createElement method by using an HTML string for the method argument."... so I'm not sure what the problem is.
And yes, i know i could do this easily in jquery, unfortunately we're not using jquery. Am i overlooking something really simple here?