$ ("#mytable tr"). Find ("Td:nth-child (1)") 1 means get the first column of each row
$ ("#mytable tr"). Find ("Td:nth-child (3)") 3 means get the third column of each row
Today in the project, just use to add a row to the specified table, delete a row, directly to Google, the search out of things is not satisfactory, not the function is not good is the same, it is a waste of time not to please, and so on their own hands encapsulated, and now the code to share out, to avoid repeating the wheel, If you have any questions, please do not make any personal attacks, quack ...
Demand Scenarios
1), add a row
Support to add a row and configurable on any row, such as can add a row in the first row, add a row in the second row, the first line to add a row, the penultimate row to add a row, with the change in demand will not affect.
Prerequisites: The number of rows needs to exist in the table or the add is unsuccessful.
2), delete a row
Supports dynamic deletion of a row.
Show the results first, as you would like to study the code well.
1. The original interface is as follows:
2, add a row, if you want to add a line to click the "Add" button, now click Two will automatically add two lines, the effect is as follows:
3, delete a row, if you want to delete the specified line, first select the row and then click on the "Delete" button to delete (this is not nonsense ~ ~ ~ ~), now select a row, the effect is as follows:
4, delete the selected row, now click the "delete" button will delete the selected row, the effect is as follows:
The code is as follows:
<%@ page language= "java" pageencoding= "UTF-8"%> <! DOCTYPE HTML PUBLIC "-//w3c//dtd HTML 4.01 transitional//en" >
Use jquery to add a row to a specified table dynamically and delete a row