Back

Explore Courses Blog Tutorials Interview Questions
0 votes
2 views
in Web Technology by (47.6k points)

What is the best method in jQuery to add an additional row to a table as the last row?

Is this acceptable?

$('#myTable').append('<tr><td>my data</td><td>more data</td></tr>');

Are there limitations to what you can add to a table like this (such as inputs, selects, number of rows)?

1 Answer

0 votes
by (106k points)
edited by

Below is the recommended way of adding table row in jQuery:-

$('#myTable tr:last').after('<tr>...</tr><tr>...</tr>');

In the after() method you can include anything as long as it's valid in HTML, including multiple rows as per the example above.

Want to become a Web Developer, join Web Development Courses now!

Related questions

0 votes
1 answer
0 votes
1 answer
0 votes
1 answer

Browse Categories

...