Skip to content
Advertisement

Add/delete row from a table

I have this table with some dependents information and there is a add and delete button for each row to add/delete additional dependents. When I click “add” button, a new row gets added to the table, but when I click the “delete” button, it deletes the header row first and then on subsequent clicking, it deletes the corresponding row.

Here is what I have:

Javascript code

JavaScript

HTML code

JavaScript

Advertisement

Answer

JavaScript with a few modifications:

JavaScript

And the HTML with a little difference:

JavaScript
User contributions licensed under: CC BY-SA
3 People found this is helpful
Advertisement