After entering a text in the input field and click the "Add" button, a new row should appear with the text written. Each new row has to be added under the previous. The "Delete button (x)" Should alow the user to delete the exact row. No matter which row has been deleted the order of the rows should remain the same.
For now, I made a jQuery that inserts only the text from the input to a new tr. How to make it to add dynamically a new row number? How can i make button that looks like X to delete the row ?
$(document).ready(function(){
$(".add-row").click(function(){
var name = $("#name").val();
var markup = "<tr><td>" + name + "</td></tr>";
$("table tbody").append(markup);
})});
<script src="https://cdnjs.cloudflare.com/ajax/libs/jquery/3.3.1/jquery.min.js"></script>
<form>
<input type="text" id="name" placeholder="Name">
<input type="button" class="add-row" value="Add Row">
</form>
<table>
<thead>
<tr>
<th>Name</th>
</tr>
</thead>
<tbody>
<tr>
<td>Peter Parker</td>
</tr>
</tbody>
</table>
It must be something like this https://ibb.co/eGaVQd Kind regards