The example in this article describes the method of adding and deleting rows in jquery. Share it with everyone for your reference. The specific analysis is as follows:
I recently made a voting management module and needed to add question options. For convenience, I simply implemented the addition and deletion of table rows.
Note: jquery.js needs to be introduced
First the rendering: (There are 4 rows in the form by default)
Form code:
所属问题 | ${question} | |
选项1: | | |
选项2: | | |
选项3: | | |
选项4: | |
A row count variable needs to be defined in JS, because my form has 4 rows by default (the first row, i.e. the line with id='option0' can be ignored), so the rowCount defined in JS defaults to 4.
OK, done. It's that simple.
In addition, if you need to add a line at a specified position, you need to write like this
tab is the id of the table