How to Add and Delete Rows Dynamically using jQuery

WebSolutionStuff | Jan-02-2021 | Categories : Laravel PHP jQuery HTML

In this article, we will see how to add and delete rows dynamically using jquery. Also, we will see without the page refreshing add rows and delete or remove rows. Using the .append() and .remove() methods we can dynamic add and delete rows using jquery. Also, you can delete all rows at a time using the multiple checkbox options.

The append() method is used to append or add rows inside an HTML table and the .remove() method is to remove or delete table rows as well as all data inside it from the DOM dynamically with jquery.

So, let's see dynamically add/remove rows in an HTML table using javascript and jquery add and delete rows dynamically.


<!DOCTYPE html>
<html lang="en">
<meta charset="utf-8">
<title>How to Add and Delete Rows Dynamically Using jQuery -</title>
        margin: 20px;
    form input, button{
        padding: 5px;
        width: 90%;
        margin: 20px;
		border-collapse: collapse;
    table, th, td{
        border: 1px solid #cdcdcd;
    table th, table td{
        padding: 10px;
        text-align: left;      	
  	.delete-row, h2{

<body style="border:1px solid grey">
  	<h2>How to Add and Delete Rows Dynamically Using jQuery -</h2>
        <input type="text" id="name" placeholder="Name">
        <input type="text" id="email" placeholder="Email Address">
    	<input type="button" class="add-row" value="Add Row">
                <td><input type="checkbox" name="record"></td>
                <td>[email protected]</td>
                <td><input type="checkbox" name="record"></td>
                <td>[email protected]</td>
    <button type="button" class="delete-row">Delete Row</button>
<script src=""></script>
            var name = $("#name").val();
            var email = $("#email").val();
            var markup = "<tr><td><input type='checkbox' name='record'></td><td>" + name + "</td><td>" + email + "</td></tr>";
            $("table tbody").append(markup);
        // Find and remove selected table rows
            $("table tbody").find('input[name="record"]').each(function(){






You might also like:

Recommended Post
Featured Post

Follow us
facebooklogo github instagram twitter