How to add table row in a table using jQuery? Improve Improve Like Article Like Save Share Report 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: 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. tableBody.append(markup) Example: <!DOCTYPE html> <html> <head> <title> How to add table row in jQuery? </title> <script src= "https://ajax.googleapis.com/ajax/libs/jquery/3.3.1/jquery.min.js"> </script> <style> table { margin: 25px 0; width: 200px; } table th, table td { padding: 10px; text-align: center; } table, th, td { border: 1px solid; } </style> </head> <body> <h1 style="color: green"> GeeksForGeeks </h1> <b>How to add table row in jQuery?</b> <p> Click on the button below to add a row to the table </p> <button class="add-row"> Add row </button> <table> <thead> <tr> <th>Rows</th> </tr> </thead> <tbody> <tr> <td>This is row 0</td> </tr> </tbody> </table> <!-- Script to add table row --> <script> let lineNo = 1; $(document).ready(function () { $(".add-row").click(function () { markup = "<tr><td>This is row " + lineNo + "</td></tr>"; tableBody = $("table tbody"); tableBody.append(markup); lineNo++; }); }); </script> </body> </html> Output: Before clicking the button: After clicking the button 4 times: Last Updated : 23 Apr, 2019 Like Article Save Article Previous How to set the value of a select box element using JavaScript? Next Find quotient and remainder by dividing an integer in JavaScript Share your thoughts in the comments Add Your Comment Please Login to comment...