How does jQuery dynamically Add rows with delete buttons?

Source: Internet
Author: User

How does jQuery dynamically Add rows with delete buttons?

How does jQuery dynamically Add rows with delete buttons:
In actual use, if you want to operate a table, you can add or delete rows at most. In general, dynamically added rows can also be deleted dynamically, the following is a brief introduction of how to implement this operation. Although it is relatively simple, it is still expected to provide some help to friends who need it.
The code example is as follows:

<! DOCTYPE html> 

The code above allows you to dynamically Add rows to a table, and the delete button is at the end of the table row. When you click Delete, you can delete the current row. The implementation process is described below.
I. Implementation principle:
The principle is particularly simple, that is, to declare a string first. This string is the content of the row to be added. When you click the append button, the append () the function appends the string to the end of the table. When you click the delete button, the parent node of the button, that is, the current row, is deleted.
Ii. Related reading:
1. For details about click events, see click events in jQuery.
2. For details about the parent () function, refer to the parent () method section of jQuery.
3. For the remove () function, see the remove () method section of jQuery.

The original address is: http://www.softwhy.com/forum.php? Mod = viewthread & tid = 9099.

For more information, see: http://www.softwhy.com/jquery/

Contact Us

The content source of this page is from Internet, which doesn't represent Alibaba Cloud's opinion; products and services mentioned on that page don't have any relationship with Alibaba Cloud. If the content of the page makes you feel confusing, please write us an email, we will handle the problem within 5 days after receiving your email.

If you find any instances of plagiarism from the community, please send an email to: info-contact@alibabacloud.com and provide relevant evidence. A staff member will contact you within 5 working days.

A Free Trial That Lets You Build Big!

Start building with 50+ products and up to 12 months usage for Elastic Compute Service

  • Sales Support

    1 on 1 presale consultation

  • After-Sales Support

    24/7 Technical Support 6 Free Tickets per Quarter Faster Response

  • Alibaba Cloud offers highly flexible support services tailored to meet your exact needs.