...)"."/> ...)".">

Home  >  Article  >  Web Front-end  >  How to add a row of tr in jquery

How to add a row of tr in jquery

WBOY
WBOYOriginal
2021-11-16 10:56:343098browse

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(

... )".

How to add a row of tr in jquery

The operating environment of this tutorial: windows7 system, jquery1.10.0 version, Dell G3 computer.

How to add a line of in jquery

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.

How to add a row of tr in jquery

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.

How to add a row of tr in jquery

Open the test.html file in the browser and click the button to see the effect.

How to add a row of tr in jquery

After clicking the button:

How to add a row of tr in jquery

The append() method adds a new element at the end of the specified object element.

For more programming related knowledge, please visit: Programming Video! !

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!

Statement:
The content of this article is voluntarily contributed by netizens, and the copyright belongs to the original author. This site does not assume corresponding legal responsibility. If you find any content suspected of plagiarism or infringement, please contact admin@php.cn