For illustration lets assume we have the following table in our page:
In this example the approach to adding more columns is very straightforward as we can utilize jQuery’s child and last selectors with the after modifier to add a new table row.
var newRow = '
'; $('#exampleTable1 tr:last').after(newRow); Albany New York
If a table contains a tfoot element with rows then the above will insert a row in the footer, A modification that can be done is to obtain the tbody element of the table and append the new row.
That is all there is to it simply define your new row as a string then utilize jQuery to identify where you would like that row added to the DOM.
Comments & Questions
Add Your Comment