
- HTML Tutorial
- HTML - Home
- HTML - Overview
- HTML - Basic Tags
- HTML - Elements
- HTML - Attributes
- HTML - Formatting
- HTML - Phrase Tags
- HTML - Meta Tags
- HTML - Comments
- HTML - Images
- HTML - Tables
- HTML - Lists
- HTML - Text Links
- HTML - Image Links
- HTML - Email Links
- HTML - Frames
- HTML - Iframes
- HTML - Blocks
- HTML - Backgrounds
- HTML - Colors
- HTML - Fonts
- HTML - Forms
- HTML - Embed Multimedia
- HTML - Marquees
- HTML - Header
- HTML - Style Sheet
- HTML - Javascript
- HTML - Layouts
- HTML References
- HTML - Tags Reference
- HTML - Attributes Reference
- HTML - Events Reference
- HTML - Fonts Reference
- HTML - ASCII Codes
- ASCII Table Lookup
- HTML - Color Names
- HTML - Entities
- HTML - Fonts Ref
- HTML - Events Ref
- MIME Media Types
- HTML - URL Encoding
- Language ISO Codes
- HTML - Character Encodings
- HTML - Deprecated Tags
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 Articles
- 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 to create a table caption with JavaScript DOM?
- How can we delete multiple rows from a MySQL table?
- How can we delete all rows from a MySQL table?
- 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
- MySQL: delete all rows containing string “foo” in sample table “bar”?
- How to sort rows in a table using JavaScript?
- How to layout table cells, rows, and columns with JavaScript?
- 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
- Fetch random rows from a table with MySQL

Advertisements