Add Edit Delete Table Row Example using JQuery

By Hardik Savani | April 13, 2019 | Category : Javascript Bootstrap HTML jQuery

In this post, i want to share with ou how to add edit and delete rows of a html table with javascript or jquery. i will create very simple example of add new table row using jquery, edit html table row using jquery and remove table row on button click.

If you are beginner for jquery and you want to create some awesome example like add, edit and delete function with jquery. then this example will help to create start way to insert update delete operation using jquery.

we will use bootstrap for design so it look's very nice. we will simply create one html file and include bootstrap and jquery file. after that we write code of jquery to create new table row, edit row data and delete row data using jquery.

So, let's see bellow example and demo for testing.


<!DOCTYPE html>



<title>Add Edit Delete Table Row Example using JQuery -</title>

<link rel="stylesheet" href="" />

<script src=""></script>



<div class="container">

<h1>Add Edit Delete Table Row Example using JQuery -</h1>


<div class="form-group">


<input type="text" name="name" class="form-control" value="Paresh" required="">


<div class="form-group">


<input type="text" name="email" class="form-control" value="[email protected]" required="">


<button type="submit" class="btn btn-success save-btn">Save</button>



<table class="table table-bordered data-table">




<th width="200px">Action</th>






<script type="text/javascript">



var name = $("input[name='name']").val();

var email = $("input[name='email']").val();

$(".data-table tbody").append("<tr data-name='"+name+"' data-email='"+email+"'><td>"+name+"</td><td>"+email+"</td><td><button class='btn btn-info btn-xs btn-edit'>Edit</button><button class='btn btn-danger btn-xs btn-delete'>Delete</button></td></tr>");




$("body").on("click", ".btn-delete", function(){



$("body").on("click", ".btn-edit", function(){

var name = $(this).parents("tr").attr('data-name');

var email = $(this).parents("tr").attr('data-email');

$(this).parents("tr").find("td:eq(0)").html('<input name="edit_name" value="'+name+'">');

$(this).parents("tr").find("td:eq(1)").html('<input name="edit_email" value="'+email+'">');

$(this).parents("tr").find("td:eq(2)").prepend("<button class='btn btn-info btn-xs btn-update'>Update</button><button class='btn btn-warning btn-xs btn-cancel'>Cancel</button>")



$("body").on("click", ".btn-cancel", function(){

var name = $(this).parents("tr").attr('data-name');

var email = $(this).parents("tr").attr('data-email');







$("body").on("click", ".btn-update", function(){

var name = $(this).parents("tr").find("input[name='edit_name']").val();

var email = $(this).parents("tr").find("input[name='edit_email']").val();



$(this).parents("tr").attr('data-name', name);

$(this).parents("tr").attr('data-email', email);








You can also see demo and i hope it can help you...

Hardik Savani
My name is Hardik Savani. I'm a full-stack developer, entrepreneur and owner of Aatman Infotech. I live in India and I love to write tutorials and tips that can help to other artisan. I am a big fan of PHP, Javascript, JQuery, Laravel, Codeigniter, VueJS, AngularJS and Bootstrap from the early stage.
Follow Me: Github Twitter
***Do you want me hire for your Project Work? Then Contact US.

We are Recommending you: