I kind of feel like I'm abusing the DOM with my code...
for(var i=0; i<json.length; ++i){
var newobj = document.createElement("div");
var inner = "<img src='"+json[i].picture+"' alt='Item preview' class='icon' />";
inner += "<p>"+json[i].id+"<br />qty:"+json[i].qty;
inner += "<a href=\"javascript:clearProduct('"+json[i].id+"')\">";
inner += "<img alt='Seperator' src='images/form-sep.gif' />";
inner += "<img src='images/cross.png' alt='Remove this item.' title='Remove this item.' />";
inner += "</a></p>";
newobj.innerHTML = inner;
newobj.className = "cart_item";
$('cartitems').appendChild(newobj);
$('cartcount').innerHTML = json.length;
}
Is there a better way to do this? I mean, yes I could through and use createElement for each element and setting each attribute separately but that seems like a lot just when this is so simple. Is there a better way?