Home > Web Front-end > JS Tutorial > body text

How to add a row in jquery

藏色散人
Release: 2021-11-17 11:51:25
Original
3739 people have browsed it

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.

How to add a row <tr> in jquery

## 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.

How to add a row <tr> in jquery

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.

How to add a row <tr> in jquery

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.

How to add a row <tr> in jquery

In the test.html file, use the button tag to create a button with the button name "Add a line of tr".

How to add a row <tr> in jquery

In the test.html file, bind the onclick event to the button button. When the button is clicked, the addonetr() function is executed.

How to add a row <tr> in jquery

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.

How to add a row <tr> in jquery

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

How to add a row <tr> in jquery

Recommended learning: "

jquery video tutorial"

The above is the detailed content of How to add a row in jquery. For more information, please follow other related articles on the PHP Chinese website!

Related labels:
source:php.cn
Statement of this Website
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
Popular Tutorials
More>
Latest Downloads
More>
Web Effects
Website Source Code
Website Materials
Front End Template
About us Disclaimer Sitemap
php.cn:Public welfare online PHP training,Help PHP learners grow quickly!