You'll need to use the content
variable instead of querying the DOM for these elements (e.g., $('#gvCapitalByYear')
) because the content hasn't been attached to the DOM yet.
Once you wrap the table HTML as a jQuery object, you can query and manipulate it just like any other jQuery object. The object is "live" so you won't need to reassign the content
variable once you append more content.
var content = $('<table id="gvCapitalByYear" cellspacing="0" cellpadding="2"><tbody></tbody></table>');
//later, add as many rows as you like
content.find('tbody').append('<tr><td>Some Content Here</td></tr>');
Also, table
, tbody
and tr
elements aren't self-closing tags, you will need to have an opening tag and closing tag for each for this to be valid HTML.