

- Trending Categories
Data Structure
Networking
RDBMS
Operating System
Java
iOS
HTML
CSS
Android
Python
C Programming
C++
C#
MongoDB
MySQL
Javascript
PHP
- Selected Reading
- UPSC IAS Exams Notes
- Developer's Best Practices
- Questions and Answers
- Effective Resume Writing
- HR Interview Questions
- Computer Glossary
- Who is Who
With JavaScript DOM delete rows in a table?
To delete rows in a table in JavaScript, use the DOM deleteRow() method.
Example
You can try to run the following code to learn how to delete rows in a table. The code deletes rows one at a time −
<!DOCTYPE html> <html> <head> <script> function captionFunc(x) { document.getElementById(x).createCaption().innerHTML = "Demo Caption"; } </script> </head> <body> <table style="border:2px solid black" id="newtable"> <tr> <td>One</td> <td>Two</td> </tr> <tr> <td>Three</td> <td>Four</td> </tr> <tr> <td>Five</td> <td>Six</td> </tr> </table> <p> <input type="button" onclick="captionFunc('newtable')" value="Display Table Caption"> </p> <p> <input type="button" value="Delete Row" onclick="document.getElementById('newtable').deleteRow(0)"> </p> </body> </html>
- Related Questions & Answers
- Delete only specific rows in a table with MySQL
- How to add rows to a table using JavaScript DOM?
- HTML DOM Table rows Collection
- How can we delete multiple rows from a MySQL table?
- How can we delete all rows from a MySQL table?
- How to create a table caption with JavaScript DOM?
- Delete more than one rows from a table using id in MySQL?
- Delete only some rows from a table based on a condition in MySQL
- How to layout table cells, rows, and columns with JavaScript?
- Fetch random rows from a table with MySQL
- MySQL query to delete table rows if string in cell is matched
- Delete records from a MySQL table with IN() in a single query
- Count rows having three or more rows with a certain value in a MySQL table
- How to replace rows in a MySQL table with conditions?
- Combine objects and delete a property with JavaScript
Advertisements