Skip to content
Related Articles

Related Articles

Improve Article
Save Article
Like Article

How to add table row in a table using jQuery?

  • Last Updated : 23 Apr, 2019

jQuery can be used to add table rows dynamically. This can be used in web applications where the user may need to add more rows if required.

Steps to add table row:

Hey geek! The constant emerging technologies in the world of web development always keeps the excitement for this subject through the roof. But before you tackle the big projects, we suggest you start by learning the basics. Kickstart your web development journey by learning JS concepts with our JavaScript Course. Now at it's lowest price ever!

  • The required markup for the row is constructed.

    markup = "<tr><td> + information + </td></tr>"
  • The table body is selected to which the table rows to be added.

    tableBody = $("table tbody")
  • Finally the markup is added to the table body.



<!DOCTYPE html>
        How to add table row in jQuery?
    <script src=
        table {
            margin: 25px 0;
            width: 200px;
        table th, table td {
            padding: 10px;
            text-align: center;
        table, th, td {
            border: 1px solid;
    <h1 style="color: green">
    <b>How to add table row in jQuery?</b>
        Click on the button below to
        add a row to the table
    <button class="add-row">
        Add row
                <td>This is row 0</td>
    <!-- Script to add table row -->
        let lineNo = 1;
        $(document).ready(function () {
            $(".add-row").click(function () {
                markup = "<tr><td>This is row " 
                    + lineNo + "</td></tr>";
                tableBody = $("table tbody");


  • Before clicking the button:
  • After clicking the button 4 times:

My Personal Notes arrow_drop_up
Recommended Articles
Page :

Start Your Coding Journey Now!