How to create repeatable table with unique ID's using jQuery
- by milbert
I need to create a table structure that can be "copied" and populated with a new set of data. However, each table must have unique IDs for functions that must access them later. For example:
<table class="main">
<thead><tr><th class="header"></th></tr></thead>
<tbody>
<tr class="row"><td class="col0"></td><td class="col1"></td></tr>
</tbody>
</table>
My current thought is to use jQuery to load the table from a seperate html file into a variable. Using this saved table I could then create a function that copies it, traverses the table to add an ID to each section where information will need to be appended from a seperate data source, and return this new table.
I am new to jQuery and feel like I may be missing an easier/better way to accomplish this. Any help on this subject would be appreciated.