I have an "add" button that inserts this row everytime it is clicked. Each row has an Edit and Delete button.
//html
<tr class="insertedRow">
<td><input type="hidden" class="name" /></td>
<td><input type="hidden" class="age" /></td>
<td>
<input type="button" class="edit" class="btn" value="Edit" />
<input type="button" class="delete" value="Delete" />
</td>
</tr>
I have this jQuery to Delete the corresponding row that you want deleted. But I can't figure out how to select "name" and "age" of the corresponding row when you click "Edit" The code I have right now is always targeting the first inserted row. Any ideas? Thanks.
I think I need to somehow select the parent.parent of the "Edit" button and then target the "name" and "age" id's.
//jQuery
$(".delete").live('click',function() {
$(this).parent().parent().remove();
});
$(".edit").live('click',function() {
$('.name').clone().attr('type','text').insertAfter('.name').prev().remove();
$('.age').clone().attr('type','text').insertAfter('.age').prev().remove();
});