jQuery Example build table with n columns
by Ben Clayton
HTML
<table></table>
JavaScript
var data = ['one', 'two', 'three', 'four', 'five', 'six', 'seven', 'eight'];
var numCols = 2;
$.each(data, function(i) {
if(!(i%numCols)) tRow = $('<tr>');
tCell = $('<td>').html(data[i]);
tCell.on('click',function(){alert('Hi')});
$('table').append(tRow.append(tCell));
});