 
  Data Structure Data Structure
 Networking Networking
 RDBMS RDBMS
 Operating System Operating System
 Java Java
 MS Excel MS Excel
 iOS iOS
 HTML HTML
 CSS CSS
 Android Android
 Python Python
 C Programming C Programming
 C++ C++
 C# C#
 MongoDB MongoDB
 MySQL MySQL
 Javascript Javascript
 PHP 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>Advertisements
 