showing results for - "add edit delete from table using jquery"
Line
21 Jan 2020
1$(function(){
2	//Add, Save, Edit and Delete functions code
3	$(".btnEdit").bind("click", Edit);
4	$(".btnDelete").bind("click", Delete);
5	$("#btnAdd").bind("click", Add);
6});
7
Ilaria
18 Jan 2019
1function Save(){
2	var par = $(this).parent().parent(); //tr
3	var tdName = par.children("td:nth-child(1)");
4	var tdPhone = par.children("td:nth-child(2)");
5	var tdEmail = par.children("td:nth-child(3)");
6	var tdButtons = par.children("td:nth-child(4)");
7
8	tdName.html(tdName.children("input[type=text]").val());
9	tdPhone.html(tdPhone.children("input[type=text]").val());
10	tdEmail.html(tdEmail.children("input[type=text]").val());
11	tdButtons.html("<img src='images/delete.png' class='btnDelete'/><img src='images/pencil.png' class='btnEdit'/>");
12
13	$(".btnEdit").bind("click", Edit);
14	$(".btnDelete").bind("click", Delete);
15}; 
16
Elona
09 Jan 2018
1function Delete(){
2	var par = $(this).parent().parent(); //tr
3	par.remove();
4}; 
5
Naomie
13 Mar 2018
1function Add(){
2	$("#tblData tbody").append(
3		"<tr>"+
4		"<td><input type='text'/></td>"+
5		"<td><input type='text'/></td>"+
6		"<td><input type='text'/></td>"+
7		"<td><img src='images/disk.png' class='btnSave'><img src='images/delete.png' class='btnDelete'/></td>"+
8		"</tr>");
9	
10		$(".btnSave").bind("click", Save);		
11		$(".btnDelete").bind("click", Delete);
12}; 
13