How to create repeatable table with unique ID's using jQuery

Posted by milbert on Pro Webmasters See other posts from Pro Webmasters or by milbert
Published on 2012-07-03T15:22:34Z Indexed on 2012/07/03 15:25 UTC
Read the original article Hit count: 185

Filed under:
|
|

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.

© Pro Webmasters or respective owner

Related posts about html

Related posts about JavaScript