...)"."/> ...)".">
Home > Article > Web Front-end > How to add a row of tr in jquery
In jquery, you can use the append() method to add a row of tr. The function of this method is to add a new element at the end of the specified element object. The syntax is "table object.append(
... )".
The operating environment of this tutorial: windows7 system, jquery1.10.0 version, Dell G3 computer.
How to add a line of 1. Create a new html file and name it test.html, which is used to explain jquery Dynamically add a row of tr to the specified table. In the test.html file, use the table tag, tr tag, and td tag to create a table with two rows and two columns. Next, we will dynamically add a row to the table. In the test.html file, set the id of the table tag to testtd, which is mainly used to obtain the table object through this id below. In the test.html file, use the button tag to create a button with the button name "Add a line of tr". In the test.html file, bind the onclick click event to the button button. When the button is clicked, the addonetr() function is executed. 2. In the js tag, create the addonetr() function. Within the function, define a variable html to save the table rows that need to be added. Obtain the table object through id (testtb), and use the append() method to add a row to the table. Open the test.html file in the browser and click the button to see the effect. After clicking the button: The append() method adds a new element at the end of the specified object element. For more programming related knowledge, please visit: Programming Video! ! in jquery
The above is the detailed content of How to add a row of tr in jquery. For more information, please follow other related articles on the PHP Chinese website!