Skip to content

Instantly share code, notes, and snippets.

@psibi
Created October 22, 2012 16:34
Show Gist options
  • Save psibi/3932397 to your computer and use it in GitHub Desktop.
Save psibi/3932397 to your computer and use it in GitHub Desktop.
Build table using jQuery
var jobject = $(html_response_data);
$("caption.featureInfo",jobject).remove(); //Removing Caption tag
var mytable = "<table class=\"featureInfo\"><thead>";
var trs = $('tr',jobject);
trs.each(function(i,n) { //console.log($(n).html());
if (i==0) { mytable += $(n).html(); mytable += "</thead><tbody>";}
else { mytable += "<tr>"; mytable +=$(n).html(); mytable += "</tr>";}
});
mytable += "</tbody></table>";
$('#nodelist').html(mytable); //Put the table in the div whose id is "nodelist"
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment