How to add table row in a table using jQuery? Last Updated : 20 Sep, 2024 Comments Improve Suggest changes Like Article Like Report In jQuery, adding a row to a table refers to dynamically inserting a new table row (<tr>) into an existing HTML table. This functionality allows developers to update and manage table content in real-time, enhancing interactivity and user experience without reloading the page.Steps to add table rowThe 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: In this example we demonstrates how to dynamically add table rows using jQuery. When the "Add row" button is clicked, a new row with updated text is appended to the table's body. html <!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: Comment More infoAdvertise with us Next Article How to add table row in a table using jQuery? sayantanm19 Follow Improve Article Tags : JavaScript Web Technologies jQuery-Misc Similar Reads How to select all even/odd rows in table using jQuery ? In this article, we will see how to make a table by selecting the alternate rows i.e. selecting the even or odd rows by clicking on the respective buttons. This feature can be useful at the time of selecting the specific data/elements of either of the rows or to highlight the table of data for displ 3 min read How to Add Edit and Delete Table Row in jQuery ? In this article, we will create an example of how to add, edit and delete table rows in jQuery. For creating this functionality we need to know about the basics of the HTML table, jQuery basic functionality. Table row: An HTML table is a combination of rows and columns. The table row is in the horiz 3 min read How to Count Number of Rows and Columns in a Table Using jQuery? Given an HTML document containing a table, the task is to count the number of rows and columns in that table using JQuery. There are a few methods available in jQuery to count the number of rows and columns in an HTML table. Table of Content By iterating through the rows and columnsBy using the leng 3 min read How to highlight alternate table row using jQuery ? In this article, we will set the highlight on an alternative table row using jQuery. The :nth-child(2n) selector is used to select the alternative row and the addClass() method is used to set the style of the alternative rows. Syntax: $(tr:nth-child(2n)").addClass("GFG"); Here, we will create a simp 2 min read How to Dynamically Add/Remove Table Rows using jQuery? We will dynamically add/remove rows from an HTML table using jQuery. jQuery provides us with a lot of methods to perform various tasks. To dynamically add and remove the rows from an HTML table, we are also going to use some of these jQuery methods like append(), remove(), etc.Adding a rowTo add a r 3 min read Like