I'm new to jQuery, and am using it to dynamically construct chunks of a page.
The created HTML is what I want, but I'm not sure if the way I'm generating it is sensible or idiomatic.
function setupIndex()
{
$(document.body).append($("<img/>", {src : 'logo.png'}));
var div = $("<div/>", {"class" : "content"}).appendTo(document.body);
div.append("<h2/>", { text :'My Panels'});
div.append($("<table/>", {id : 'maintable'}));
}
function addPanel(name, desc)
{
if (!$("#maintable"))
setupIndex();
var row = $("<tr/>",{"class":"panels"}).appendTo("#maintable");
var div = $("<td/>").appendTo(row);
div.append($("<h3/>").append($("<a/>", { text : name, href : name + "/index.html"})));
div.append(document.createTextNode(desc));
div = $("<td/>").appendTo(row);
var anc = div.append($("<a/>", {href: name + "/index.html"}));
anc.append($("<img/>", { css : {width : "200px", height : "auto"}, src : name + "/thumbnail.png"}));
}