class HTMLDocument
Node createHTML(string text)
A fast and simple way to create HTML DOM nodes at runtime.
// Since input are self-contained in a single JavaScript object,
// templates can be remotely loaded as JSON.
var json = ['A',{href:'http://llamalab.com'},['LlamaLab']];
var llamalab = document.toHTML.apply(document, json);
// Creating a DOM tree.
document.body.appendChild(document.createHTML(
'UL',[
'LI',llamalab,
'LI',['A',{href:'http://slashdot.org'},['Slashdot']],
'LI',[document.getElementById('moveThisLink')],
]
));
name - Element tag name.[attrs] - Object with attributes.[children] - Array with children, with same syntax as this function.text - Text node content.node - Node to include as child.
HTMLDocumentanddocumentwith functionality for easy cross-browser HTML node creation.