I am trying to add a row to a table. I found that we can use the clone() method to duplicate an existing row. My table has two text inputs in it in two different <
Try this:
var clone = $("#table-1 tr:last").clone().find('input').val('').end();
- .find() the
elements in the clone
- set the .val() of the
elements to ''
,
- call .end() so that the cloned
is stored in the variable instead of the
elements.
If you intend to append it to the table immediately, add .insertAfter("#table-1 tr:last") to the end.
var clone = $("#table-1 tr:last").clone().find('input').val('').end().insertAfter("#table-1 tr:last");
- 热议问题