D
D
Dmitry25902021-06-09 18:20:43
JavaScript
Dmitry2590, 2021-06-09 18:20:43

How to copy multiple rows of a table and paste them into the same table before the last row?

I have an html table

<table>
<tbody class="itemsParent">
 <tr class="item-child">
                                                <td></td>
                                                <td></td>
                                                <td></td>
                                                <td></td>
                                                <td></td>
                                                <td></td>
                                            </tr>
 <tr  class="item-child">
                                                <td></td>
                                                <td></td>
                                                <td></td>
                                                <td></td>
                                                <td></td>
                                                <td></td>
                                            </tr>
 <tr class="item-child">
                                                <td></td>
                                                <td></td>
                                                <td></td>
                                                <td></td>
                                                <td></td>
                                                <td></td>
                                            </tr>
 <tr  class="item-child">
                                                <td></td>
                                                <td></td>
                                                <td></td>
                                                <td></td>
                                                <td></td>
                                                <td></td>
                                            </tr>
 <tr>
                                                <td></td>
                                                <td></td>
                                                <td></td>
                                                <td></td>
                                                <td></td>
                                                <td>
<a class="add" href="#">Добавить</a>
</td>
                                            </tr>
</tbody>
</table>


You need to copy the table rows with the item-child class and paste them into the same table before the last item-child row up to the row with the button when you click on the Add button. I know how to do it with one line, but how to do it with several lines????

And how to delete inserted rows when clicking on the Delete button?

Please help it is very necessary!

Answer the question

In order to leave comments, you need to log in

Didn't find what you were looking for?

Ask your question

Ask a Question

731 491 924 answers to any question