Created
December 13, 2017 12:30
-
-
Save crispy-computing-machine/0551586a3e59d5eb713f78b1cd865a94 to your computer and use it in GitHub Desktop.
Create Table With Javascript/jQuery
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
var testCount = 101; | |
// Main elements | |
var $table = $("<table>", { | |
'border':'1' | |
}); | |
var $thead = $("<thead>"); | |
var $tbody = $("<tbody>"); | |
// Add some headers | |
for(headerNum = 1; headerNum < testCount; headerNum++){ | |
$thead.append($('<th>', { | |
'text':'Column ' + headerNum | |
})); | |
} | |
// Add some rows | |
for(rowCount = 1; rowCount < testCount; rowCount++) { | |
newTr = $('<tr>'); | |
for(rowColumnCount = 1; rowColumnCount < testCount; rowColumnCount++) { | |
newTr.append($('<td>', { | |
'text':'Row:' + rowCount + " Col:" + rowColumnCount, | |
})); | |
} | |
$tbody.append(newTr); | |
} | |
// Add table to DOM | |
$table.append($thead); | |
$table.append($tbody); | |
$table.appendTo("body"); |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment