Vue.Js Delete Table Row

Vue.Js Delete Table Row On Button Click We can remove the table row by index or id on button click very easily. Here in this article we are going to explain how you to delete the table row. You can also use our online editor to edit and run the code online.

Delete Table Row On Button Click in Vue.JS Example

Here in this example we have removed the table row by the row index, we have deleted the item at that index.


<!DOCTYPE html>
 <script src=""></script>
<div id="app">
<tr><th>Sample Table</th></tr>
<tr v-for="(content, index) in tableRows">
  <td>{{content}}</td><td><button @click='deleteTableRow(index)' >Delete</button></td>
 <button @click='addTableRow()' >Add New Row</button>
 new Vue({
  el: '#app',
  data: {
    tableRows:['Table Row 1', 'Table Row 2'],
    addTableRow: function () { 
      this.tableRows.push("Table Row "+this.counter);
    deleteTableRow: function (idx) { 
      this.tableRows.splice(idx, 1);      
	} });

Try it »

If you run the above example it will produce the output something like this-

Vue.Js Delete Table Row Example


Add Comment

📖 Read More