Add Edit Delete Table Row Example using JQuery

Today, We want to share with you Add Edit Delete Table Row Example using JQuery.In this post we will show you add edit delete in html table with javascript, hear for java-script delete table row onclick we will give you demo and example for implement.In this post, we will learn about add edit and delete rows of a html table with an example.

Add Edit Delete Table Row Example using JQuery

There are the Following The simple About remove table row on button click Full Information With Example and source code.

As I will cover this Post with live Working example to develop how to edit data in html table using javascript, so the some major files and Directory structures for this example is following below.

Step 1: Include jQuery library

At first we need to include jQuery Latest library file.


Step 2: JavaScript/jQuery Source Code:

This file All the Data contains the following JavaScript/jQuery Source codes.

$("form").submit(function(e){
        e.preventDefault();
        var name = $("input[name='name']").val();
        var email = $("input[name='email']").val();
     
        $(".data-table tbody").append(""+name+""+email+"");
    
        $("input[name='name']").val('');
        $("input[name='email']").val('');
    });
   
    $("body").on("click", ".btn-delete", function(){
        $(this).parents("tr").remove();
    });
    
    $("body").on("click", ".edit-data", 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('');
        $(this).parents("tr").find("td:eq(1)").html('');
    
        $(this).parents("tr").find("td:eq(2)").prepend("")
        $(this).hide();
    });
   
    $("body").on("click", ".cancel-data", function(){
        var name = $(this).parents("tr").attr('data-name');
        var email = $(this).parents("tr").attr('data-email');
    
        $(this).parents("tr").find("td:eq(0)").text(name);
        $(this).parents("tr").find("td:eq(1)").text(email);
   
        $(this).parents("tr").find(".edit-data").show();
        $(this).parents("tr").find(".update-data").remove();
        $(this).parents("tr").find(".cancel-data").remove();
    });
   
    $("body").on("click", ".update-data", 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").find("td:eq(0)").text(name);
        $(this).parents("tr").find("td:eq(1)").text(email);
     
        $(this).parents("tr").attr('data-name', name);
        $(this).parents("tr").attr('data-email', email);
    
        $(this).parents("tr").find(".edit-data").show();
        $(this).parents("tr").find(".cancel-data").remove();
        $(this).parents("tr").find(".update-data").remove();
    });

Step 3: HTML Source Code:

This file contains the following HTML Markup Source codes.


Name Email Action
Web Programming Tutorials Example with Demo

Read :

Summary

You can also read about AngularJS, ASP.NET, VueJs, PHP.

I hope you get an idea about jquery add edit delete table row example.
I would like to have feedback on my infinityknow.com blog.
Your valuable feedback, question, or comments about this article are always welcome.
If you enjoyed and liked this post, don’t forget to share.

Leave a Comment