Skip to content

Instantly share code, notes, and snippets.

@j127
Last active December 27, 2015 09:59
Show Gist options
  • Save j127/7307563 to your computer and use it in GitHub Desktop.
Save j127/7307563 to your computer and use it in GitHub Desktop.
// Create a table and attach to the target div
myTable = $('<table><caption><thead><tbody>').appendTo('#myDiv');
// Loop through object and put the keys/values in table cells on the page
Object.keys(obj).forEach(function(key) {
if (obj[key] !== null) {
currentRow = $('<tr>');
cell1 = $('<td>').text(key).appendTo(currentRow);
cell2 = $('<td>').text(obj[key]).appendTo(currentRow);
currentRow.appendTo('tbody');
});
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment