How to add a row of
in jquery: 1. Create a new html file; 2. Create a table using the table tag; 3. Create the addonetr() function; 4. Get the table through "id(testtb)" Object; 5. Use the append() method to add a row to the table. ## The operating environment of this article: Windows7 system, jquery3 .Version 2.1, DELL G3 computer
jquery How to add a row of
? jquery dynamically adds a row of tr to the specified table:
Create a new html file, named test.html, to explain how jquery dynamically adds a line 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 event to the button button. When the button is clicked, the addonetr() function is executed. In the js tag, create the addonetr() function, and 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. Recommended learning: "jquery video tutorial"
The above is the detailed content of How to add a row